Hello everyone first time posting here, I have spent hours trying to figure out how to write this program that our instructor has given to us as an assignment. http://en.m.wikipedia.org/wiki/Bogosort#section_3Instructions are bellow

Frequently, the temperatures on the news are given in Centigrade rather than Fahrenheit. The formula for conversion is

C = 5 / 9 * F - 32 

My friend does it another way; he says that a good approximation when converting Fahrenheit to centigrade is to take half the Fahrenheit temperature and subtract 15. How good an approximation is it?

Write a program that takes the following three temperatures in Fahrenheit:

    38
    -45.38
    89.3495

and for each, outputs

    the correct temperature in Centigrade
    the approximated temperature in Centigrade
    the percentage error in the approximation 

see this link for a description of percentage error: http://wiki.answers.com/Q/What_is_the_percent_error_formula

We will not be doing input in this program. Instead, code the initial three temperature into your program as constants, i.e. your program should begin with

int main 

const float temp1 = 38;
const float temp2 = -45.38;
const float temp3 = 89.3495;

Your output should be in tabular form, with headings, column aligned, right justified, with each temperature printed in fixed format with two decimal places accuracy. The percentage error should be to the nearest tenth of a percent and always positive, (use <cmath> library function called fabs absolute value).

Your output should look exactly like this:
http://imageshack.us/photo/my-images/152/93424739.jpg/

Edited 4 Years Ago by pyTony: format made readable

You write the code. We help you debug it. No cheating here! For whatever it's worth (FWIW), I always use the formula %C = (%F-32)x(5/9) or the inverse, %F = (%Cx(9/5))+32. Why bother with approximations? What is the purpose of inexactitude for this?

Why bother with approximations? What is the purpose of inexactitude for this?

It's obvious.
1) It's part of the assignment to get the grade
2) It shows a possible approximation of the temperature conversion
3) Teaches how to calculate a percentage error via program

Many times there's more to an assignment than the mere calculation of a very simple formula. This is one such case. The percentage error is clearly the main purpos of this assignment.

I have spent hours trying to figure out how to write this program

You have the three input values. Looks like you need one or more functions to provide the outputs for display. Are you familiar with writing functions? Are you comfortable with how to store the values produced?

I am sorry, yes it is an assignment, I did write the code up to the values and past that part I am not able to write the formula because I do not know :(.
Instructor is not that great at explaining and he just rushes through the lesson as if we are professionals when this is clearly a beginners class.

I am not familiar with writing functions, nor am i comfortable on how to store values.

If anyone can help me it would be great, if not thank you for trying :/

#include <iostream>
#include <cmath>

int main std();
{
const float temp1 = 38;
const float temp2 = -45.38;
const float temp3 = 89.3495;
}

We certainly can try. I don't know about anyone else here, but
1) I can't see you screen from where I am so I don't know what you did wrong,
2) I don't know what you need help with because my psychic powers aren't working today.

I am sorry, yes it is an assignment, I did write the code up to the values and past that part I am not able to write the formula because I do not know :(.
Instructor is not that great at explaining and he just rushes through the lesson as if we are professionals when this is clearly a beginners class.

I am not familiar with writing functions, nor am i comfortable on how to store values.

If anyone can help me it would be great, if not thank you for trying :/

Judging from the code you've posted and from what you've said above, you're asking for more than help, you're asking us to do your instructor's job for him and teach you the fundamentals. You probably need to go back to your instructor and talk this one over, because it appears to be well beyond your grasp.

This article has been dead for over six months. Start a new discussion instead.