Lab 02:   Temperature Conversion

Description:      Use console I/O for temperature conversions.

INPUT:

  • A Fahrenheit temperature in floating point format.
OUTPUT:
  • The temperature, converted to Celsius, displayed in a complete sentence.
PROCESSING:
  • Formula for temperature conversion:  C = 5/9 (F - 32)
  • This formula must be "translated" into correct (logically & syntactically) C++ code.
PROGRAM INTERACTION:
      Enter Fahrenheit temperature: 82.4
      82.4 Fahrenheit is equivalent to 28.0 Celsius.
TEST DATA SETS:
82.4
212
-5
LOGIC:
  • Prompt for Fahrenheit temperature.
  • Calculate Celsius equivalent.
  • Display output exactly as shown:

  • ____ Fahrenheit is equivalent to ____ Celsius.
CODING:
  • Start a New program called celsius.cpp .
  • Select identifiers and data types for the data objects.
  • Code expressions to calculate celsius temperature correctly.

 

CALCULATIONS:
Q. What is 5 divided by 9?     A. Zero, because of C++ integer division
Q. How do I code 5 / 9 so result is not an int ?     Think.

SUBMIT:

  • A document with the following:
    • Source code listing
    • Logic plan
    • Output screenshots

 

SUGGESTED PROGRAM STRUCTURE:
// Project Name:        Assignment 2
// Programmer Name:
// Date Written:
// Description:         Convert Fahrenheit to Celsius

#include <iostream> // Header File for console I/O
using namespace std;

//  Begin main Function Definition
int main()
{
// Initialization
                              Declare Data Objects Here
// Display Identification on screen
cout << "Assignment 2"<< endl;
cout << "programmed by your name here" << endl << endl;

// Input
                              Code Input Statements Here
// Processing
                              Code Calculation Statements Here
// Output
                              Display Results Here
// Termination
// Indicate normal EOJ
cout  << endl << "Normal job termination" << endl;
return 0;

}    // end of main


Return to TOP

! You are using a version 4 browser or older. If you are experiencing any problems with scrolling, please reload the page.