Lab: Input, output, calculations
Chapter 2
Requirements
Create a C++ program that meets the following requirements:
- Place documentation comments at the beginning of the source code. These comments should include the course, your name, the date, and the assignment (Lab 1). Check the style guide for this course for details.
- Write a single statement (not three) using cout that will display the following three lines on the screen:
Your name
Programming Lab 1
The current date
- Use cout to output a blank line to the screen.
- Define two variables of data type int. You may name them anything you want. Initialize them with the literal values 7 and -14
- Output the two integer variables and their product using the following format:
7 * -14 = -98
The result must be calculated by the program and you must be outputting the values of variables or expressions
- NOT hard-coded values. Note that you will be outputting a combination of variables and literals
(such as " * " to display the multiplication symbol). If your statement has any numeric literals
in it (such as 7, -14, or -98), then it is incorrect.
- Define two variables of a floating point type (float or double). You may name them anything you want.
Initialize them with the literal values 78.25 and 34.3
- Define a third variable of a floating point type (float or double). You may name it anything you want.
- Divide the first float variable by the second float variable and store the result in the third float variable.
- Output the floating point variables using the following format:
78.25 / 34.3 = 2.2813
The result must be calculated by the program and you must be outputting the values of variables
- NOT hard-coded values. Note that you will be outputting a combination of variables and literals
(such as " / " to display the division symbol). If your statement has any numeric literals in it
(such as 78.25, 34.3, or 2.2813), then it is incorrect.
Points (10 points total)
- 2 points: using the standard program structure and including the required comments as given in the project specifications
- 2 points: outputting your name, class and date using cout
- 2 points: defining the variables as stated above and assigning the specified values to the variables
- 2 points: doing the multiplication and division using the variables
- 2 points: displaying the multiplication and division properly using the variable values
Example run of program
Dave Klick
Programming Lab 1
2017-01-28
7 * -14 = -98
78.25 / 34.3 = 2.2813