A9 Application Development - sheerazwalid/COMP-I GitHub Wiki
Assignment Folder
Place source code files for this assignment in a folder named application within your Cloud9 workspace.
Exercise 1: Unit conversion (10 points)
Write a console program that converts meters into feet and inches. The program starts by asking the user for a measurement in meters. The program should accept a floating point number. After getting the number, the program computes the number of feet and inches equal to the specified number of meters. The program outputs feet and inches as whole numbers. The program should round the number of inches correctly. Test that your program produces the following outputs for the given inputs.
Input | Output |
---|---|
1 | 3 ft 3 in |
2 | 6 ft 7 in |
0.3049 | 1 ft 0 in |
0.3048 | 1 ft 0 in |
0.3047 | 1 ft 0 in |
Note: There are 39.3700787 inches in a meter.
Hint: Read meters into a double. Convert to integer inches adding .5 to round result to nearest whole inches.
Exercise 2: Computing change (10 points)
Write a program that prompts the user to enter in a number of cents less than 100 and prints out the equivalent in quarters, dimes, nickels and pennies. Verify the correctness of your code with the following test cases.
cents | quarters | dimes | nickels | pennies |
---|---|---|---|---|
99 | 3 | 2 | 0 | 4 |
17 | 0 | 1 | 1 | 2 |
30 | 1 | 0 | 1 | 0 |
12 | 0 | 1 | 0 | 2 |
EXTRA CREDIT 1: Tic Tac Toe (10 points)
Write a console program that plays Tic Tac Toe with the user.
The program displays a 3 by 3 grid, which is initially blank. When the player takes a turn, an X is added to the grid. When the computer takes a turn, a O is added to the grid. After each turn, simply print out the grid. As a result, old states of the grid will scroll up in the console window.
After each turn, your code needs to check for a win or a tie. If either of these conditions are met, then the program displays the result and terminates.
There are plenty of tic tac toe programs on the Internet that you can look up. However, copying someone else's code to solve this problem will not help you develop the software development skills needed to write original code. For this reason, I will not accept work that was copied from the Internet.
EXTRA CREDIT 2: Graphics Programming (10 points)
Implement your tic tac toe program using the SDL2 library. Your program should not be a console program; rather, it should run inside a graphics window.
You will not be able to do this problem using the Cloud9 workspace because the workspace only supports console-based programs and not programs that run in operating system windows. Therefore, if you work on this problem, you will need to work on a local computer with a C++ compiler.
Submit Your Work
Submit your work by sending the url of your Cloud9 workspace to the teaching assistant and CC me. The subject line of your email should be 201 Assignment: Application.