Hi! I saw a post on this site that exhibited the same exact problem that I have for a homework assignment and while it was solved, my issue with the homework assignment is different. The C++ program that I wrote asked the user to input information but once you enter a number, everything in "" is posted on to the screen at one time. Below I will post the instructions for the homework assignment and, the program that I wrote, and I would really appreciate any help or advice that anyone is able to issue.Thank you.

The following table lists the freezing and boiling points of several substances. Write a program that asks the user to enter a temperature, and then shows all the substances that will freeze at that temperature and all that will boil at that temperature. For example, if the user enters -20 the program should report that water will freeze and oxygen will boil at that temperature.

#include <iostream>
using namespace std;

int main()
{int point; //Freezing and Boiling points

cout<<"Please enter a number for freezing and or boiling points(F):";
cin>>point;

cout<<"Freezing Point (F)"<<endl;
if(point>=-173)cout<<"Ethyl alcohol will freeze"<<endl;
if(point>=-38)cout<<"Mercury will freeze"<<endl;
if(point>=-362)cout<<"Oxygen will freeze"<<endl;
if(point>=32)cout<<"Water will freeze"<<endl;

cout<<"\nBoiling Point (F)"<<endl;
if(point<=172)cout<<"Ethyl alcohol will boil"<<endl;
if(point<=676)cout<<"Mercury will boil"<<endl;
if(point<=-306)cout<<"Oxygen will boil"<<endl;
if(point<=212)cout<<"Water will boil"<<endl;

cout<<"How'd I'd do Rich?"<<endl<<endl<<"Program end";

return 0;
}

Recommended Answers

All 3 Replies

I'm not really sure what your actual problem is? Are you saying that all cout in your program is call no matter what the user inputs?
if that's the case try
if(point<=somevalue){
cout<<"blablabla"<<endl;
}

That was exactly my issue thanks so much geogia!! It is working as it should now.

*geojia

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.