skip to main
|
skip to sidebar
C++ Programs
Based on cusat cs 3rd sem 2009 lab cycle
Thursday, May 13, 2010
Differnt temprature scale(Farenheit/celsius/kelvin).
5. Write a class that stores a temprature that can be specified in any of the differnt temprature scale(Farenheit/celsius/kelvin).
#include<iostream.h> #include<conio.h> #include<process.h> class temprature { int c,k,f; public: void celsius(); void farenheit(); void kelvin(); void show(); }; void temprature::celsius() { cout<<"\nEnter the temprature in celsius "; cin>>c; f=(c*1.8)+32; k=c+273; } void temprature::farenheit() { cout<<"\nEnter the temprature in farenheit "; cin>>f; c=(f-32)*1.8; k=c+273; } void temprature::kelvin() { cout<<"\nEnter the temprature in kelvin "; cin>>k; c=273-k; f=(c*1.8)+32; } void temprature::show() { cout<<"\n Temprature "; cout<<"\n------------"; cout<<"\n Celsius= "<<c; cout<<"\n Kelvin= "<<k; cout<<"\n Farenhiet= "<<f; } void main() { clrscr(); temprature t; int c; while(1) { cout<<"\n Menu "; cout<<"\n---------"; cout<<"\n1.Celsius\n2.Kelvin\n3.Farenhiet\n4.Exit"; cout<<"\nEnter ur choice"; cin>>c; switch(c) { case 1: t.celsius(); t.show(); break; case 2: t.kelvin(); t.show(); break; case 3: t.farenheit(); t.show(); break; case 4: exit(0); default: cout<<"\n Invalid Choice"; } } getch(); }
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
Home
8085 programming
Datastructure
Graphics programming
8086 Programming
LEX, YACC and parsers
Operating System
Programzz!
Add two date using operator overloading
Add two date using class
Decrement time by one using operator overloading(E...
Add two time using operator overloading(External q...
Compare two string. use operator overloading(Exter...
Matrix multiplcation(External Questn-2009)
Difference between two dates
Generic programming
File manipulation
Pure Virtual Function
Virtual Function
Multipath Inheritance
Hybrid Inheritance
Hierarchical inheritance
Addition of two distances using friend function
Class to class conversion
Basic to class and class to basic conversion
Operator functions as friend functions
Function overloading.
Static & Constant function
User defined string functions
Complex numbers using operator overloading.
Inline function
Add two time
Differnt temprature scale(Farenheit/celsius/kelvin).
Students details- using class
Students details- using structure
Check whether a date is valid or not
pass by value, pass by address, pass by refrence
Followers
Blog Archive
▼
2010
(29)
►
December
(2)
►
October
(4)
►
July
(1)
▼
May
(22)
Generic programming
File manipulation
Pure Virtual Function
Virtual Function
Multipath Inheritance
Hybrid Inheritance
Hierarchical inheritance
Addition of two distances using friend function
Class to class conversion
Basic to class and class to basic conversion
Operator functions as friend functions
Function overloading.
Static & Constant function
User defined string functions
Complex numbers using operator overloading.
Inline function
Add two time
Differnt temprature scale(Farenheit/celsius/kelvin).
Students details- using class
Students details- using structure
Check whether a date is valid or not
pass by value, pass by address, pass by refrence
About Me
Arun Ramesh
View my complete profile
No comments:
Post a Comment