I am working on a study guide for my C++ Prgramming Final Exam and I am having t
ID: 3581343 • Letter: I
Question
I am working on a study guide for my C++ Prgramming Final Exam and I am having trouble with the following question:
Consider the following program:
/*
Ch2Proj15.cpp
This program allows the user to input a starting and an ending temperature. Within this temperature range, the program should output the temperature and the corresponding sound velocity in one degree
Celsius increments.
*/
#include <iostream>
using namespace std;
int main()
{
const double VELOCITY_AT_ZERO = 331.3;
// meters per second
const double INCREASE_PER_DEGREE = 0.61;
// meters per second
// Declare variables for the start and end temperatures, along with
// a variable that we'll increment as we compute the temperatures.
int temp, start, end;
// Prompt the user to input the starting temperature
cout << "Enter the starting temperature, in degrees Celsius: ";
cin >> start;
cout << "Enter the ending temperature, in degrees Celsius: ";
cin >> end;
// Set cout such that we only show a single digit after //the decimal point
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(1);
cout << " DegreeCelsius Sound velocity (m/s) "temp = start;
while (temp <= end)
{
cout << temp << “ ” << (VELOCITY_AT_ZERO + (temp * INCREASE_PER_DEGREE)) << endl;
temp++;
}
return 0;
}
Using the table below, assume the program has read in the data shown in the “start, end” column.
What is displayed in the “Degree Celsius Sound velocity (m/s)” column?
Hints:
1) you may use the Windows Calculator to calculate the outputs.
2) Pay attention to the formatting.
3) Space provided so that you can write all the output lines whenever several iterations take place.
e.g start, end Degree Celsius Sound velocity (m/s) 1, 1 1 331.9 1.-1 -2, 0 1, 2 0, 1 0,0Explanation / Answer
Please let me know in case of any issue.
1)
DegreeCelsius Sound velocity (m/s)
-1 330.7
2)
DegreeCelsius Sound velocity (m/s)
-2 330.1
-1 330.7
0 331.3
3)
DegreeCelsius Sound velocity (m/s)
1 331.9
2 332.5
4)
DegreeCelsius Sound velocity (m/s)
0 331.3
1 331.9
5)
DegreeCelsius Sound velocity (m/s)
0 331.3
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.