The Assignment
Working with a partner, write a C++ program which follows this basic algorithm:
- Input two integer values (x and y).
- Compute x operator y, using the +, -, *, /, and % operators.
- Output the values of x and y.
- Output the computed values.
An example of the overall screen output would be the following:
You entered 10 and 5. 10 + 5 = 15 10 – 5 = 5 10 * 5 = 50 10 / 5 = 2 10 % 5 = 0
Use the C++ compiler on the iPad. Look for the icon:
One student should be the “driver” and the code should be broadcast via Apple TV. Begin by creating a new C++ file called BasicMath.cpp
. Next, copy and paste this starter code into the file:
#include <iostream> #include <iomanip> using namespace std; int main() { // declare storage for the variables... int x = 0, y = 0, result = 0; // input the values... cin >> x >> y; /* Add code here, using the variable "result" to store the values computed using the math operators. Compute, then output, then compute, then output... */ // return "success" to the operating system (OS)... return 0; }
Modify the code to complete the assignment. When you have completed the assignment, demonstrate it for the instructor.