Getting Stuck on an assignment please help?!

Hi all i'm so utterly lost on this assignment, I haven't had any luck finding a tutor, Please help. My instructor hasn't been very helpful.
Here's the assignment:
Create a C++ console application that generates a simple Fahrenheit to
Celsius conversion table based on user input.Prompt the user to enter the start, stop, and step values before the counter control loop using cin and cout. Use your fah variable to iterate the for loop. place your conversion formula within the body of the for loop. Display fah and calculated cel values within the loop.

This is what I have so far;
Have I done it? If i havent i dont know where to go from here.
#include <iostream>

using namespace std;

int main()
{
int x, n, fah;
int step;
int stop;
int start;
double cel;
cout << "How Many Times : ";
cin >> n;

for (x = 0; x < n; x++)
{
cout << "Enter Fahrenheit: ";
cin >> fah;
cel = 5 * (fah - 32) / 9;
cout << "Celsius is " << cel << endl;
}
return 0;
}


No, this should not be solved over a private message.

Assistance should be given in an open forum. You can get far more input in an open discussion than in a private message, not to mention that any mistakes made or incorrect information given can be corrected by more experienced member of the community.

Development THRIVES in public and open discussions on sites like these. In addition, any other person that comes along this post may need the help in a topic similar to this. By doing a PM, it deprives anyone else that comes along this post from learning from your past experience and the input that forum members can provide.

It sounds like you want the user to enter a lower bound, upper bound, and step value and print out all the converted values between those values with the step amount between different values?

Perhaps something like this would help
1
2
3
4
5
6
int lower = 0, upper = 0, step = 0;
//Get the values from the user
for (int i = lower; i <= upper; i += step)
{
  //Do your stuff
}
I sent you a message.
Did i terrible mess up, im so embarassed
Thank you, i will try that. I thought i was good with computers until i took this class. Sorry @jayhawkzombie if i overstepped.
No no, I don't mean to make you feel bad, sorry. I'm more trying to encourage Gentleguy to stop trying to get everyone to PM him for help. Who knows how many PMs he's gotten and how many threads have been halted because of that.

If you've come to a solution, then you can at least post your solution in case someone else comes along this thread who has a similar problem. If not, then I encourage you to discuss solutions/attempts here in the public thread so others can contribute. We'll never make you feel stupid for trying to solve something, even if it isn't right. We all had to learn at one point, like you are not.

Letting us know what part of it is causing you the most trouble will help the most, and you can tackle it one bit at a time.
I totally get that!
This is the whole assignment he gave me: (I may not totally understand what he is all requesting me to do!)

Objective: To create a C++ console application that generates a simple Fahrenheit to
Celsius conversion table based on user input.

General Instructions: The overall design and format of your program is up to you. You
should prompt the user to input Fahrenheit start, stop, and step values for your table.
Using these values your program should generate a user friendly Fahrenheit to Celsius
conversion table as illustrated below. Celsius output values should be rounded or
formatted to one decimal place.

cel=5*(fah-32)/9

Design Hints: Prompt the user to enter the start, stop, and step values before the counter
control loop using cin and cout. Use your fah variable to iterate the for loop. place
your conversion formula within the body of the for loop. Display fah and calculated cel
values within the loop.

//prompt the user for the start, stop, and step values

for(fah=start; fah<=stop; fah+=step)
{
// conversion formula
// display formatted fah and cel values
}
Sample Run:
Enter Start Fahrenheit: 80
Enter Stop Fahrenheit: 100
Enter Step: 2

Fah Cel
------ ------
80 26.7
82 27.8
84 28.9
86 30.0
88 31.1
90 32.2
92 33.3
94 34.4
96 35.6
98 36.7
100 37.8

From that prompt I did this:

#include <iostream>

using namespace std;

int main()
{
int x, n, fah;
double cel;
cout << "How Many Times : ";
cin >> n;

for (x = 0; x < n; x++)
{
cout << "Enter Fahrenheit: ";
cin >> fah;
cel = 5 * (fah - 32) / 9;
cout << "Celsius is " << cel << endl;
}
return 0;
}






// so what i've done will tell me what Fahrenheit temp is in Celsius.
What i'm confused on is the start, stop and step. and where i even put them without getting a thousand error messages.
Last edited on
Posting the whole thing is better.

You'd want to get those from the user before you enter the loop. Perhaps instead of "How many times?", you might want to prompt "Start? : ", then read in where they want to start; "Stop? ", then read in where they want to stop; "How much between each temp? ", then read in the step.

In your loop, you start from 0, but since the user tells you where you start from, where do you think the loop should start at? Likewise, where should the loop stop at? What condition would you check? x++ will increment by 1, but the user does tell you how much they want between each, so how might you want to change that?
That defeats the purpose of helping OP come to the solution on their own. You just gave the solution.
no but wait on line 19 what is the purpose of "----------- ------------" endl;
Just to separate things and make the output look nicer. It has no functional purpose.
see that"s how brain fried I am! Thank you, Im going to play with it some more, I really do want to understand this.
closed account (48T7M4Gy)
Enter Start Fahrenheit : 45
Enter Stop Fahrenheit : 67
Enter Step : 2

Fah Cel
------ ------
45 7.22222
47 8.33333
49 9.44444
51 10.5556
53 11.6667
55 12.7778
57 13.8889
59 15
61 16.1111
63 17.2222
65 18.3333
67 19.4444
 
Exit code: 0 (normal program termination)


gentle will explain his program if you have any questions, but the output from his suggested fixes might also help.
Last edited on
Topic archived. No new replies allowed.