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
}
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
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.
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?