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.
- Declare the variables x, y, and z as double.
- Declare the variables i, and j as integers and
initialize both to 0 within the declaration statment.
- Write an assignment statement to give the value 4.56 to y
- Write an assignment statement to give the value 0.1 to x
- Print the message "Enter an integer"
- Receive a value from the user for i
- Add x and i and store the result in y
- Add x and i and store the result in j
- Print the message "Y is: " immediately followed
by the value for y
- On a new line, print the message "J is: " immediately followed
by the value for j
- On a new line, print the message "Z is: " immediately followed
by the value for z
- Set z's value to be j's value.
- Multiply the value in x by 5 (storing the result in z)
- Multiply the quantity (y+y/6) with z (store the result in z)
- Print the message "X is: " immediately followed
by the value for X. (Note: NO new line)
- On a new line, print the message "Y is: " followed by a tab
and then the value for Y
- On the same line as the previous output, print the message "Z is:
" followed by two tabs and then the value for z
- Print two blank lines and then the message "I is: " followed
by a space and then the value for i
- On the same line as i's value, print the message "J is: "
followed by a new line and then the value for j
- Print two blank lines followed by your name
This program will be handed in using two different means.
- 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.
- Print out the code and hand it in
The code will be graded based on these requirements:
- Syntax & Following Directions(5 pts)
Used correct statments
Statements syntactically correct
- Output Format (5 pts)
All output present
Formatted correctly
- Structured Programming (5 pts)
Documentation
Indentation
Declaration Placement