CIS 150 Lab: Input, output, calculations
• Create a working C++ program
• Declare and use variables
• Use cout to display literals
• Use cout to display variable values
• Perform simple calculations using C++
Create a C++ program that meets the following requirements:
1. 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.
2. Write a single statement (not three) using cout that will display the following three lines on the screen:
3. Programming Lab 1
4. The current date
5. Use cout to output a blank line to the screen.
6. Define two variables of data type int. You may name them anything you want. Initialize them to the literal values 7 and -14.
7. 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 C++ numeric literals in it (such as 7, -14, or -98), then it is incorrect.
8. 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
9. Define a third variable of a floating point type (float or double). You may name it anything you want.
10. Divide the first float variable by the second float variable and store the result in the third float variable.
11. Output the floating point variables using the following format:
12. 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 C++ statement has any numeric literals in it (such as 78.25, 34.3, or 2.2813), then it is incorrect.
13. Submit your .cpp file in Desire2Learn when done.
Example run of program
Programming Lab 1
7 * -14 = -98
78.25 / 34.3 = 2.2813
• 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