Lab Assignment #1

Due Tuesday, July 8 at the beginning of class

Complete the C++ program provided so that it correctly converts a Celsius temperature to its Fahrenheit equivalent. The formula for converting Celsius to Fahrenheit is:

Fahrenheit = 9 / 5 * Celsius + 32

Below are two sample runs of the program. The numbers in bold were typed by the user.

	Enter a temperature in Celsius: 22
	The temperature in Fahrenheit is 76.1

Enter a temperature in Celsius: 100

The temperature in Fahrenheit is 212

The C++ program you will complete (name it program1.cpp):

///////////////////////////////////////////////////////////////////// // Student name: // Student ID: // Course: CS161 // Assignment: #1 // Due date: 7-8-97 // // Description: program1.cpp // // // /////////////////////////////////////////////////////////////////// #include <iostream.h> #include <iomanip.h> void main(void) { float celsius, fahrenheit; cout << "Enter a temperature in Celsius: "; cin >> celsius; // calculations done here cout << "The temperature in Fahrenheit is " << setprecision(2); cout << fahrenheit << endl; }

This first assignment is designed to make you comfortable with doing programming assignments. If you have done the reading and paid attention in class, it shouldn't take you more than 30 minutes. Make sure you name the C++ file program1.cpp so everyone is consistent.

How to submit your programs

Back to Outline