# i need help with c++



## deleted24062011 (Aug 6, 2005)

i know i have to use a for loop to get this going, but i can't figure it out? any ideas on how to get me going would be great if you could im on aol @aim1crzy.

Write a C++ program that coverts Fahrenheit to Celsius temperature in increments of 5 degrees. The initial value of Fahrenheit temperature and the total conversions to be made are to be requested as user input during program execution.


----------



## mgoldb2 (Dec 16, 2004)

aim1crzy said:


> i know i have to use a for loop to get this going, but i can't figure it out? any ideas on how to get me going would be great if you could im on aol @aim1crzy.
> 
> Write a C++ program that coverts Fahrenheit to Celsius temperature in increments of 5 degrees. The initial value of Fahrenheit temperature and the total conversions to be made are to be requested as user input during program execution.


With out giving you the acutrally code I going to give you it in psuodocode.

int temp
int count

print "enter intial farienhight temperture"
input temp
print "enter number of 5 degree increaments"
input count

loop when count>0
print temp
print "fairenheight equal in celrious is"
print (5/9)*(temp-32)
temp = temp +5
count=count-1
end loop

I gave it to you in psuodocode so you can learn how to translate a problem into c++ your self.


----------



## LoneWolf071 (Nov 10, 2004)

We Don't Give Out Code Here, If you Give Us What You Already have as your code, we will be able to help you fix a specific problem with your code.


----------



## Stu_computer (Jul 7, 2005)

Well done mgoldb2.

aim1crzy, to learn a programming language you have to do the work to learn it properly, that means reading and testing until you understand.

We can point you in the right direction, but we do not do the work for anyone.
-------------------------------------------
A programming language is no different than anything else, it may look like a big thing but it really is just a bunch of smaller things put together. Questions are like that too, so break it down into smaller parts and solve them.

-convert Fahrenheit to Celsius temperature
-repeat output in increments of 5 degrees
-user input: initial value
-user input: total conversions

So, basically it's four small tasks that answer this problem.

You already understand that some form of looping is needed to satisfy the "repeat output" task, so here are a few tips for the rest...

For and While loops have a basic structure that never changes regardless of their content. So make your basic for/while loops and prove they work then you can copy and use them anywhere.

A FOR loop is used when you have control over the data it uses.
A WHILE loop is used when the data is suspect.

Think about it for a moment, what if the user presses a key that's not a number, what do you need to do to ensure the input data are numbers. What messages should you send to the user.

Do you have good input data now?

What's the main task? What code solves just that task (and does nothing else), test it and verify it works, main task solved.


----------



## menriquez (Nov 21, 2005)

But wait! This *is* C++..sooooooo...

We need a virtual Temperature class that we can derive into Fahrenheit and Celsius classes...probably the constructors could do the conversions. Maybe add a Kelvin class, for absolute reference....

Since we are using a virtual base class, we wouldn't need to overload the convert() function...it would handle the different inherited classes automatically...a neat feature of polymorphism...


----------

