Overview:
This second programming assignment will make use of several things we've learned (or will shortly learn) since the first programming assignment. This includes floating point numbers (defining them, reading them in from keyboard, etc), functions (we'll have more than just a main() function in this program), returning values from functions, and switch statements.
Brief Description:
This program will present the user with a main menu of options which the user can choose from to perform simple unit conversions. Once the user has chosen an option from the menu, the program should provide a brief explanation of the conversion to be performed and allow the user to enter a quantity to be converted. The program should then display the converted result. After performing the conversion, the program should return the user back to the main menu.
Details:
When your program first runs, it should print out your name, the course number (“CS102-03”), and the programming assignment name (“Programming Assignment #2”), each on a new line. Then, the program should skip a line (i.e., print a blank line), and print a brief description of what the program does.
After the description, the program should print out a “main menu” similar to the following:
When the user picks an option from the menu, the program should take in input from the user and perform the conversion, along with proper prompts. For example, if the user selects option “a”, the program should ask the user to input the number of kilometers to be converted, and the program should print out the converted number. After the conversion is performed, the program should return to the main menu.
When the user enters “q” at the main menu, the program should quit immediately.
I've included an “example run” on the next page, which should clarify exactly what information is to be printed and with what formatting.
Specific Implementation Requirements:
The menu should be implemented as a switch
Each conversion should be done by a function that takes a single argument of a floating point Each function should return a floating point number. There are 6 conversions to be done, so there should be 6 of these functions.
All input from the keyboard and output to the screen should be done in main – nowhere
All functions should have appropriate comments explaining what data the function takes in, what
data the function returns, and what the function does (this includes main!).
Conversion from kilometers to miles should be done by multiplying the number of kilometers by 0.621371.
Conversion from miles to kilometers should be done by multiplying the number of miles by 1.60934.
Conversion from meters to feet should be done by multiplying the number of meters by 28084.
Conversion from feet to meters should be done by multiplying the number of feet by 3048.
Conversion from centimeters to inches should be done by multiplying the number of centimeters by 393701.
Conversion from inches to centimeters should be done by multiplying the number of inches by 2.54.
Submission:
All programming assignments are to be submitted electronically. Programming assignments should be done in Visual Studio 2017. For the electronic submission, just make a zip file of the Visual Studio 2017 project folder for your project and submit that via Canvas. Grading late assignments is really time consuming (seriously – I didn't realize this until I started grading), so don't turn in any assignment late unless you've made arrangements with me.
As always, do your own work.
Example Run:
Jacob Hauenstein
CS102-04 Programming assignment 2
This program will present you with a menu.
Select from the menu to choose from common length unit conversions. When you are done performing conversions, enter "q".
Here is the menu. Enter your choice (or q to quit):
Convert kilometers to miles
Convert miles to kilometers
Convert meters to feet
Convert feet to meters
Convert centimeters to inches
Convert inches to centimeters Your choice: a
Enter the length in kilometers: 1 That's 0.621371 miles.
Here is the menu. Enter your choice (or q to quit):
Convert kilometers to miles
Convert miles to kilometers
Convert meters to feet
Convert feet to meters
Convert centimeters to inches
Convert inches to centimeters Your choice: b
Enter the length in miles: 1 That's 1.609340 kilometers.
Here is the menu. Enter your choice (or q to quit):
Convert kilometers to miles
Convert miles to kilometers
Convert meters to feet
Convert feet to meters
Convert centimeters to inches
Convert inches to centimeters Your choice: q
Hints:
Remember that one of the problems with reading in a single character is that when the user presses Enter, a '\n' character is entered into the input buffer as well. You'll have to find a way to throw out the '\n' or your program will have issues. We’ll discuss this some in class.
When I grade these, I will be checking for the following things:
Code compiles and executes without crashing (2 points)
The code is consistently and appropriately formatted (spacing is consistent, ) (2 points)
Comments are present and appropriate (1 point)
The program prints the author name, class section, etc. (1 point)
The program returns to the menu after doing a unit conversion (2 points)
The menu is implemented with a switch statement (2 points)
The conversions are calculated outside of the main function (2 points)
Conversions are all performed correctly (8 points)
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of