CIS 150 Lab: Input, output, calculations

Objectives

  • 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++

Lab requirements

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:
    Your name Programming Lab 1 The current date
  3. Use cout to output a blank line to the screen.
  4. Define two variables of data type int. You may name them anything you want. Initialize them to the literal values 7 and -14.
  5. 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.
  6. 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
  7. Define a third variable of a floating point type (float or double). You may name it anything you want.
  8. Divide the first float variable by the second float variable and store the result in the third float variable.
  9. 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 C++ statement has any numeric literals in it (such as 78.25, 34.3, or 2.2813), then it is incorrect.
  10. Submit your .cpp file in Desire2Learn when done.

Example run of program

Dave Klick Programming Lab 1 2017-23-08 7 * -14 = -98 78.25 / 34.3 = 2.2813

Rubric

  • 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