Below is a copy of a C++ program on file progL6.cpp. This file is in the same directory as this exercise.
// Program Convert converts a temperature from Fahrenheit to
// Celsius or a temperature from Celsius to Fahrenheit
// depending on whether the user enters an F or a C.
#include <iostream>
using namespace std;
int main ()
{
char letter; // Place to store input letter
int tempIn; // Temperature to be converted
int tempOut; // Converted temperature
cout <<"Input Menu" << endl << endl;
cout <<"F: Convert from Fahrenheit to Celsius"
<< endl;
cout <<"C: Convert from Celsius to Fahrenheit"
<< endl;
cout <<"Type a C or an F, then press return."
<< endl;
cout <<"Type an integer number, then press return."
<< endl;
cin >> letter;
cin >> tempIn;
if (letter == 'C')
tempOut = // fill in formula;
else
tempOut = // fill in formula;
cout << "Temperature to convert: " << tempIn << endl;
cout << "Converted temperature: " << tempOut << endl;
return 0;
}
The formula for converting Celsius to Fahrenheit is
9 * (the value to be changed) / 5 + 32
and Fahrenheit to Celsius is
5 * (value to be changed - 32) / 9
Below is a copy of a C++ program on file prog7.cpp.
// Program Grade prints appropriate messages based on a
// grade read from the keyboard.
#include <iostream>
using namespace std;
int main ()
{
int grade;
cout << "Enter an integer grade between 50 and 100."
<< " Press return. " << endl;
cin >> grade;
if // Fill in if expression
cout << "Congratulations!" << endl;
return 0;
}
When completed, program Grade reads an integer value and writes an appropriate message.