Assignment: #arithmetic Due: 2/26/2017 Points: 5

Specification

Write an interactive application that uses C++'s arithmetic operators.

Create a new file for this program that contains the following code.

   #include <iostream>
   using namespace std;

   int main(int, char**) {
      // YOUR_CODE_GOES_HERE
   }

Use the cerr object to prompt the user to enter an integer.

Define an int variable.

Use the cin object to read the user entered integer.

   cerr << "Enter an integer: ";
   int n;
   cin >> n;

The program uses the user entered input to print the following in the order listed. [Note: n is the input, while y and z store values that are calcuated using n.]

   the opposite of n is y
   n doubled is y
   one-half of n is y
   n squared is y
   the reciprocal of n is y
   one-tenth of n is y and y squared is z
   n minus the last digit of n is y  [???]
   the sum of n and n+1 and n+2 is y

This program requires the use of all five arithmetic operators: add (+), subtract (-), multiply (*), divide (/), and modulus (%).

Example runs for the inputs 37, 101, -42, 3141592.

Enter an integer:  37
the opposite of 37 is -37
37 doubled is 74
37 one-half of 37 is 18.5
37 squared is 1369
the reciprocal of 37 is 0.027027
one-tenth of 37 is 3.7 and 3.7 squared is 13.69
37 minus the last digit of 37 is 30
the sum of 37 and 38 and 39 is 114

Enter an integer: 101
the opposite of 101 is -101
101 doubled is 202
101 one-half of 101 is 50.5
101 squared is 10201
the reciprocal of 101 is 0.00990099
one-tenth of 101 is 10.1 and 10.1 squared is 102.01
101 minus the last digit of 101 is 100
the sum of 101 and 102 and 103 is 306

Enter an integer: the opposite of -42 is 42
-42 doubled is -84
-42 one-half of -42 is -21
-42 squared is 1764
the reciprocal of -42 is -0.0238095
one-tenth of -42 is -4.2 and -4.2 squared is 17.64
-42 minus the last digit of -42 is -40
the sum of -42 and -41 and -40 is -123

Enter an integer: 3141592
the opposite of 3141592 is -3141592
3141592 doubled is 6283184
3141592 one-half of 3141592 is 1.5708e+06
3141592 squared is -234551744
the reciprocal of 3141592 is 3.1831e-07
one-tenth of 3141592 is 314159 and 314159 squared is 9.8696e+10
3141592 minus the last digit of 3141592 is 3141590
the sum of 3141592 and 3141593 and 3141594 is 9424779