-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added New C++ Programs
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <iostream> | ||
using namespace std; | ||
class temperature | ||
{ | ||
double cel; | ||
double fah; | ||
public: | ||
temperature(); // Constructor | ||
void convert(); | ||
void print(); | ||
}; | ||
temperature::temperature() | ||
{ | ||
cout << "Enter temperature in degree celsius: \n"; | ||
cin >> cel; | ||
} | ||
void temperature::convert() | ||
{ | ||
fah = cel*1.8000+32.00; | ||
} | ||
void temperature::print() | ||
{ | ||
cout<< "\nThe degree Fahrenheit Temperature is: \n"; | ||
cout << fah; | ||
} | ||
int main() | ||
{ | ||
temperature obj; | ||
obj.convert(); | ||
obj.print(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <iostream> | ||
using namespace std; | ||
class avg | ||
{ | ||
float a, b, c, average; // Variable for 3 subjects | ||
public: | ||
avg(); //Constructor | ||
void calculate(); | ||
void print(); | ||
}; | ||
avg::avg() | ||
{ | ||
cout << "Enter marks of 3 subjects:\t"; | ||
cin >> a >> b >> c; | ||
cout << "Calculating...."<<endl; | ||
} | ||
void avg::calculate() | ||
{ | ||
average = (a+b+c)/3; | ||
} | ||
void avg::print() | ||
{ | ||
cout << "The average of 3 numbers is: "<<average; | ||
} | ||
int main() | ||
{ | ||
avg obj; | ||
obj.calculate(); | ||
obj.print(); | ||
} |