CS C++
Assignment 1

Write and debug the following two programs. Be sure to comment your code! Note: comments that merely describe the mechanics of a line of code are generally not useful; comments should indicate what the code accomplishes, not simply what it does. Please include your name in a comment at the top of each file, along with a brief description of the program's purpose.

Program 1:

Many time-and-temperature displays give the temperature in both Fahrenheit and Celsius. Write a program that inputs a temperature in Fahrenheit (as an integer) and converts it to Celsius. The formula is:

5/9 * (Fahrenheit degrees - 32)

Your output should be formatted like this, with one decimal place in the converted temperature:

32 degrees Fahrenheit = 0.0 degrees Celsius
Program 2:

How much pizza bang do you get for the buck? Write a program that inputs the diameter of a round pizza, as an integral number of inches, and the price, as a double. Calculate and display the size of the pizza in square inches, to 2 decimal places, and the cost per square inch, displayed as a standard dollar figure (i.e. $0.40). The formula for the area of a circle: pi * radius2, or pi * diameter2 / 4. Use a constant variable for the value of pi.

What to turn in:

Printouts of the source (.cpp) file for each program, as well as printouts of 2 sample runs for each. How you print out the sample runs depends on what compiler you use; the window it uses to display your program's interaction may not have print capabilities. If you can't figure out any other way, and you're using Windows, use PrintScreen to capture the window, paste it (into a Word document, for instance), and print it. If you're not able to print it, don't sweat it this time; I'll run and test your program myself.