81.9k views
4 votes
Write a C++ program that reads a temperature value and the letter C for Celsius or F for Fahrenheit. Print whether water is liquid, solid, or gaseous

User Djnose
by
6.2k points

1 Answer

4 votes

Answer:

(1) #include<iostream>

(2) #include<conio.h>

(3) using namespace std;

(4) void main()

(5) {

(6) float temp;

(7) char sel;

(8) cout<<“Select a temperature value in Celcius or Fahrenheit.\\”;

(9) cout<<“Press C for Celcius.\\”;

(10) cout<<“Press F for Fahrenheit.\\”;

(11) cin>>sel;

(12) switch (sel)

(13){

(14)case ‘C’:

(15) cout<<“Enter a temperature value in Celcius: “;

(16)cin>>temp;

(17) if(temp<=0)

(18) {

(19) cout<<“Water is solid at “<<temp<<” degree C.”;

(20) }

(21) else if(temp>=100)

(22) {

(23) cout<<“Water is gaseous at “<<temp<<” degree C.”;

(24) }

(25) else

(26) {

(27) cout<<“Water is liquid at “<<temp<<” degree C.”;

(28) }

(29) break;

(30) case ‘F’:

(31) cout<<“Enter a temperature value in Fahrenheit: “;

(32) cin>>temp;

(33) if(temp<=32)

(34) {

(35) cout<<“Water is solid at “<<temp<<” degree F.”;

(36) }

(37) else if(temp>=212)

(38) {

(39) cout<<“Water is gaseous at “<<temp<<“degree F.”;

(40) }

(41) else

(42) {

(43) cout<<“Water is liquid at “<<temp<<” F.”;

(44) }

(45) break;

(46) }

(47) getch();

(48) }

User AlexB
by
7.3k points