Assignment: #arithmetic |
Due: 09/23/02018 |
Points: 5 |

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**) { // REPLACE THIS COMMENT WITH YOUR CODE }Use the

cerrobject to prompt the user to enter an integer.Define an

intvariable.Use the

cinobject 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:

nis the input, whileyandzstore values that are calcuated usingn.]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 yThis 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 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 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 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 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