C++ Exercise 1:
Problem Specification:
Code the IPO Charts shown below for main function, getFahrenheit function, and calcCelsius function. Enter your C++ instructions into a source file named yourLastName_U5W1_EX1.cpp. Enter any appropriate comments in your code. Display the Celsius temperature in fixed-point notation with no decimal places. Save and then run the program. Test the program using the following, Fahrenheit temperatures: 32 and 212.
Hints for handling this assignment:
Hints for getting a higher grade:
|
Main Function |
|
|
IPO Chart Information |
C++ Instructions |
|
Input: |
|
|
Fahrenheit temperature |
double fahrenheit = 0.0; |
|
Processing: |
|
|
none |
|
|
Output: |
|
|
Celsius temperature |
double celsius = 0.0; |
|
Algorithm: |
|
|
|
|
|
|
|
|
getFahrenheit Function |
|
|
IPO Chart Information |
C++ Instructions |
|
Input: |
|
|
Fahrenheit temperature |
double fahrenheitTemp = 0.0; |
|
Processing: |
|
|
none |
|
|
Return Output: |
|
|
Fahrenheit temperature |
|
|
Algorithm: |
|
|
cout << “Enter temperature in Fahrenheit”; |
|
|
|
calcCelsius Function |
|
|
IPO Chart Information |
C++ Instructions |
|
Input: |
|
|
Fahrenheit temperature (as formal parameter) |
double fahrenheitTemp |
|
Processing: |
|
|
none |
|
|
Return Output: |
|
|
Celsius temperature |
double celsiusTemp = 0.0; |
|
Algorithm: |
|
|
|
|
Copy Your Code Here:
Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change.
If you are satisfied with the solution, please rate the answer. Let me know for any help with any other questions.
Thank You !
===========================================================================
#include<iostream>
#include<iomanip>
using namespace std;
double getFahrenheit (){
double fahrenheitTemp = 0.0;
cout << "Enter temperature in Fahrenheit:
";
cin>>fahrenheitTemp;
return fahrenheitTemp;
}
//Return the Celsius temperature
double calcCelsius(double fahrenheitTemp){
double celsiusTemp = 0.0;
celsiusTemp = 5.0*(fahrenheitTemp-32)/9.0;
return celsiusTemp;
}
int main(){
double fahrenheit = 0.0;
double celsius = 0.0;
fahrenheit = getFahrenheit();
celsius = calcCelsius(fahrenheit);
cout<<fixed<<showpoint<<setprecision(2);
cout<<"Temperature in Celsius Scale:
"<<celsius<<endl;
return 0;
}
=====================================================================
C++ Exercise 1: Problem Specification: Code the IPO Charts shown below for main function, getFahrenheit function,...