Homework 2 - UMBC-CMSC104/General GitHub Wiki

In this homework, we'll be reading in variables from a user and manipulating them dynamically.

We're going to write 3 programs.

Program 1

For this program, I want you to read in a Fahrenheit temperature value from the user and convert it to Celsius.

The formula to make this conversion is

Celsius = (Fahrenheit - 32) * 5/9

Title the code for this fahrenheit_to_celsius.c.

Output for this program could look something like this:

Please enter a value in Fahrenheit: 75
75 degrees Fahrenheit is 23.8889 degrees Celsius.

Program 2

This program should do the opposite -- convert Celsius to Fahrenheit. The formula for this is:

Fahrenheit = Celsius * 9/5 + 32

Title the code for this celsius_to_fahrenheit.c.

The output will look similarly to the example above.

Program 3

Finally, this program should prompt the user for their height in inches, and display it back to them in feet/inches.

For example:

Please enter your height in inches: 64
Your height is 5 feet and 4 inches.

Title the code for this inches_to_feet.c.

Submittal

To submit these, run the following commands:

submit cs104_wilson hw02 fahrenheit_to_celsius.c celsius_to_fahrenheit.c inches_to_feet.c

And you should be good to go!

Note

Feel free to refer to https://github.com/UMBC-CMSC104/General/blob/master/live-demos/variables.c for examples on how to use printf and scanf!