Please I need in 4 hours!! which part is missing?

Pages: 12
closed account (9N7koG1T)
Output a prompt using the cerr object that instructs the user to type in a temperature in °F (i.e. Fahrenheit).

Write code that converts the Fahrenheit temperature into Kelvin, Celsius, Rankine, and Reaumur.

The output of your program should be formatted as follows.

72 degree Fahrenheit in:
...Kelvin is 295.37
...Celsius is 22.22
...Rankine is 531.67
...Reaumur is 17.78

-9 degree Fahrenheit in:
...Kelvin is 250.37
...Celsius is -22.78
...Rankine is 450.67
...Reaumur is -18.22

0 degree Fahrenheit in:
...Kelvin is 255.37
...Celsius is -17.78
...Rankine is 459.67
...Reaumur is -14.22
In addition to the turning in the source code for your program, you must also submit a copy of the output generated by your program for the following three user supplied inputs: 72, 0 and -9.

Help
Printing floating-point numbers... insert near top of code...

cout.setf(ios::fixed, ios::floatfield);
closed account (9N7koG1T)
#include <iostream>
using namespace std;

int main(int,char**) {
double Fah,Kel,Cel,Ran,Rea ;

cout << " Type a temperature in Fahrenheit and press ENTER: " ;
cin >> Fah;

Kel=(Fah + 459.67) * 5 / 9;
Cel=(Fah-32) * 5/9;
Rea=(Fah-32) * 4/9;
Ran=Fah+459.67;
cout << Fah << " degree Fahrenheit in Kelvin is " << Kel << endl ;
cout << Fah << " degree Fahrenheit in Celsius is "<< Cel<< endl ;
cout << Fah << " degree Fahrenheit in Rankine is "<< Ran <<endl ;
cout << Fah << " degree Fahrenheit in Reaumur is "<< Rea <<endl ;
cout.setf(ios::fixed, ios::floatfield);

system( "pause" ) ;
return 0 ;
}

closed account (9N7koG1T)
How could I add that part?

In addition to the turning in the source code for your program, you must also submit a copy of the output generated by your program for the following three user supplied inputs: 72, 0 and -9.

Help
Printing floating-point numbers... insert near top of code...

cout.setf(ios::fixed, ios::floatfield);
closed account (9N7koG1T)
Can anybody help me??????
Some strange notion of "near the top" you have. It would make more sense if you added that before printing the floating point numbers, no?
http://www.cplusplus.com/reference/iostream/ios_base/fmtflags/
closed account (9N7koG1T)
Can you type that part, I dont understand.
What part?
closed account (9N7koG1T)
#include <iostream>
using namespace std;

int main(int,char**) {
double Fah,Kel,Cel,Ran,Rea ;

cout << " Type a temperature in Fahrenheit and press ENTER: " ;
cin >> Fah;

Kel=(Fah + 459.67) * 5 / 9;
Cel=(Fah-32) * 5/9;
Rea=(Fah-32) * 4/9;
Ran=Fah+459.67;
cout << Fah << " degree Fahrenheit in Kelvin is " << Kel << endl ;
cout << Fah << " degree Fahrenheit in Celsius is "<< Cel<< endl ;
cout << Fah << " degree Fahrenheit in Rankine is "<< Ran <<endl ;
cout << Fah << " degree Fahrenheit in Reaumur is "<< Rea <<endl ;
cout.setf(ios::fixed, ios::floatfield); //??????????

system( "pause" ) ;
return 0 ;
}

what is this for
In addition to the turning in the source code for your program, you must also submit a copy of the output generated by your program for the following three user supplied inputs: 72, 0 and -9.

Help
Printing floating-point numbers... insert near top of code...

cout.setf(ios::fixed, ios::floatfield);
closed account (9N7koG1T)
it says that you must also submit a copy of the output generated by your program for the following three user supplied inputs:72,0 and -9
and it gave that code:
cout.setf(ios::fixed, ios::floatfield);

I could not type that part into the code?
If you want to know about ios::fixed, it would have been ENTIRELY sufficient to post that line alone.
It will result in floating point numbers being printed with a fixed amount of digits after the decimal point.

See:
http://www.cplusplus.com/reference/iostream/manipulators/fixed/
http://www.cplusplus.com/reference/iostream/ios_base/fmtflags/
http://www.cplusplus.com/reference/iostream/ios_base/setf/
Last edited on
closed account (9N7koG1T)
so you say it is supposed to be alone?
the correct code is
#include <iostream>
using namespace std;

int main(int,char**) {
double Fah,Kel,Cel,Ran,Rea ;

cout << " Type a temperature in Fahrenheit and press ENTER: " ;
cin >> Fah;

Kel=(Fah + 459.67) * 5 / 9;
Cel=(Fah-32) * 5/9;
Rea=(Fah-32) * 4/9;
Ran=Fah+459.67;
cout << Fah << " degree Fahrenheit in Kelvin is " << Kel << endl ;
cout << Fah << " degree Fahrenheit in Celsius is "<< Cel<< endl ;
cout << Fah << " degree Fahrenheit in Rankine is "<< Ran <<endl ;
cout << Fah << " degree Fahrenheit in Reaumur is "<< Rea <<endl ;
cout.setf(ios::fixed, ios::floatfield);

system( "pause" ) ;
return 0 ;
}

right? that is the whole correct code?
No! What point is there to it if you change the way floating point numbers are being printed after doing the printing?
closed account (9N7koG1T)
Ohh I dont understand anythıng,, this is the assingment shit and it explain what we gonna do.. I typed the turnıng the source code for my program but I couldn't fıgure out what the hell ıs mean that part.. I dont know what am I supposed to do.. It says submit a copy output and it says this code is gonna help you
cout.setf(ios::fixed, ios::floatfield);
the all assignment is on top of the page, I thınk ı supposed to write after cout.setf(ios::fixed, ios::floatfield); (code) somethıng... somethıng::..
cout.setf(ios::fixed, ios::floatfield);

This tells cout " From now on display all my numerical output like such "

You have cout.setf(ios::fixed, ios::floatfield) at the bottom of your program when it needs to be at the start (before you use cout!).

As far as your program is concerned you don't ever tell it to use cout.setf(ios::fixed, ios::floatfield).

Yeah, that line will help you in making your output look like it should. Because, as you might have noticed, yours currently does NOT look like the reference output at all.

What's so hard to understand?
closed account (9N7koG1T)
can you write the whole,the correct code according to assignment?
@Athar

Unfortunately I think this is a case where English is not the OP's native language and they are taking a C++ course in English.
closed account (9N7koG1T)
@ georgewashere
you are exactly right men.. that's why I am here I want to learn, very like this site :))))also, thanks for information ;)
closed account (9N7koG1T)
ok, I am going to give to the lecture that code.. that;s the final reply for me.. last 15 minutes to give to homework.
@Barkin just to make sure you understand what I meant before you turn in your homework, does it look similar to this (i moved the line with cout.setf() above the cout statements) :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
using namespace std;

int main(int,char**) {
double Fah,Kel,Cel,Ran,Rea ;

cout << " Type a temperature in Fahrenheit and press ENTER: " ;
cin >> Fah;

Kel=(Fah + 459.67) * 5 / 9;
Cel=(Fah-32) * 5/9;
Rea=(Fah-32) * 4/9;
Ran=Fah+459.67;
cout.setf(ios::fixed, ios::floatfield);
cout << Fah << " degree Fahrenheit in Kelvin is " << Kel << endl ;
cout << Fah << " degree Fahrenheit in Celsius is "<< Cel<< endl ;
cout << Fah << " degree Fahrenheit in Rankine is "<< Ran <<endl ;
cout << Fah << " degree Fahrenheit in Reaumur is "<< Rea <<endl ;

system( "pause" ) ;
return 0 ;
}
Last edited on
Pages: 12