CpSc 146 Assignment 1
Fall 2022

Due: September 9th
15 points

For each of the following, write the C++ statement to perform the operation. Then create a C++ program that incorporates these statements. Run the program using 45 as the input and hand in both the program and the output. Make sure the program is documented appropriately, follows the program criteria for the course and is easy to read.

  1. Declare the variables x, y, and z as double.
  2. Declare the variables i, and j as integers and initialize both to 0 within the declaration statment.
  3. Write an assignment statement to give the value 4.56 to y
  4. Write an assignment statement to give the value 0.1 to x
  5. Print the message "Enter an integer"
  6. Receive a value from the user for i
  7. Add x and i and store the result in y
  8. Add x and i and store the result in j
  9. Print the message "Y is: " immediately followed by the value for y
  10. On a new line, print the message "J is: " immediately followed by the value for j
  11. On a new line, print the message "Z is: " immediately followed by the value for z
  12. Set z's value to be j's value.
  13. Multiply the value in x by 5 (storing the result in z)
  14. Multiply the quantity (y+y/6) with z (store the result in z)
  15. Print the message "X is: " immediately followed by the value for X. (Note: NO new line)
  16. On a new line, print the message "Y is: " followed by a tab and then the value for Y
  17. On the same line as the previous output, print the message "Z is: " followed by two tabs and then the value for z
  18. Print two blank lines and then the message "I is: " followed by a space and then the value for i
  19. On the same line as i's value, print the message "J is: " followed by a new line and then the value for j
  20. Print two blank lines followed by your name

This program will be handed in using two different means.

  1. Go to the D2L dropbox for assign1 and submit two files: one with your code and another with the output. You may use notepad to copy your code from cpp.sh into a txt file and a second notepad file for your output.
  2. Print out the code and hand it in
The code will be graded based on these requirements: