Question

In: Computer Science

You are required to write an interactive program that prompts the user for two integers X...

You are required to write an interactive program that prompts the user for two integers X and Y and performs the following tasks:

  1. Adds two numbers
  2. Subtracts Y from X
  3. Multiplies X and Y
  4. Divides X by Y
  5. Finds which numbers is larger X oy Y)
  6. Prints all the results (a , b, c, d, and e)

Program requirements:

-     The program should run as many times as the users wish

-     The program should be fully documented.

-    You must submit a hard copy of the source and a properly labeled output.

-     You should submit a digital copy of source code (in class).

-     Test your program for different values using different set of data that the users provide. .

NOTES: be sure to use basic functions of C++

(Not scan function)

USE: functions such as: using name space std, declare a main, int, loops, cin, cout, endl

be sure to comment within the program what is taking place and scentences such as:

"The sum of X and Y is:"
"The product of X and Y is:"

"The Larger number is:" (X or Y)

"Would you like to continue? (Press Y or yes or N for no. If No then program exits)

Solutions

Expert Solution

#include<iostream> //header file for performing i/o operations
using namespace std;
int main()
{
//declare two variables;
int x,y;
//declare four variables for storing the results
int a,b,c,d;
//declare status variable
char ch;
do
{
cout<<"Enter x "<<endl;
cin>>x;
cout<<"Enter y "<<endl;
cin>>y;
a=x+y; //add two numbers x and y
b=x-y; //subtract two numbers x and y
c=x*y; //multiply x and y
d=x/y; //division of x and y
cout<<"The sum of X and Y is: "<<a<<endl;
cout<<"The difference of X and Y is: "<<b<<endl;
cout<<"The product of X and Y is: "<<c<<endl;
cout<<"The division of X and Y is: "<<d<<endl;
if(x>y)
cout<<"The Largest number is X"<<endl;
else
cout<<"The Largest number is Y"<<endl;
cout<<"Would you like to continue? (Press Y for yes or N for no) ";
cin>>ch;
}while(ch=='Y');
return 0;
}

Output


Related Solutions

You are required to write an interactive JS program that prompts the user for three numbers...
You are required to write an interactive JS program that prompts the user for three numbers and then finds the sum, average, smallest, and the largest value of the numbers and prints the results labeling properly.
You are required to write an interactive program that prompts the user for ten (10) real...
You are required to write an interactive program that prompts the user for ten (10) real numbers and performs the following tasks: Reads and stores the numbers into one-dimensional array called A. The program must use a function to perform this task. Prints the content of the array. Write a function to perform this task. Calculates the sum of the numbers. Use a function to perform this task. Find the average of the numbers. Utilize a function to perform this...
You are required to write an interactive program that prompts the user for seven (7) real...
You are required to write an interactive program that prompts the user for seven (7) real numbers and performs the following tasks: Reads and stores the numbers into one-dimensional array called A. Calculates the sum of the numbers. Find the average of the numbers. Finds the smallest value of the numbers. Prints all the results with proper headings. Program requirements: -     The program must contain at least five functions using necessary parameters. These functions should read the data, perform the...
Write a program that prompts user to enter integers one at a time and then calculates...
Write a program that prompts user to enter integers one at a time and then calculates and displays the average of numbers entered. Use a while loop and tell user that they can enter a non-zero number to continue or zero to terminate the loop. (Switch statement) Write a program that prompts user to enter two numbers x and y, and then prompts a short menu with following 4 arithmetic operations: Chose 1 for addition Chose 2 for subtraction Chose...
C++ Write a program that prompts the user to enter 50 integers and stores them in...
C++ Write a program that prompts the user to enter 50 integers and stores them in an array. The program then determines and outputs which numbers in the array are sum of two other array elements. If an array element is the sum of two other array elements, then for this array element, the program should output all such pairs separated by a ';'. An example of the program is shown below: list[0] = 15 is the sum of: ----------------------...
Write a Java program that prompts a user for 10 integers. When completed it outputs the...
Write a Java program that prompts a user for 10 integers. When completed it outputs the highest number, the lowest number, the number of odd number, and the average of the numbers
Problem description Write a C++ program that prompts the user to enter two non-negative integers, firstNum...
Problem description Write a C++ program that prompts the user to enter two non-negative integers, firstNum and secondNum. The program then prints all palindromic primes (Links to an external site.) between firstNum and secondNum, inclusive. A palindromic number is a number whose digits are the same forward or backward (e.g., 12321). A palindromic prime is a prime number that is also a palindromic number (e.g., 101). You must implement and use the following functions as prototyped below: /// --------------------------------------------------------------- ///...
C Program 1. Write a program that prompts the user to enter 3 integers between 1...
C Program 1. Write a program that prompts the user to enter 3 integers between 1 and 100 from the keyboard in function main and then calls a function to find the average of the three numbers. The function should return the average as a floating point number. Print the average from main.The function header line will look something like this:float average(int n1, int n2, int n3) STOP! Get this part working before going to part 2. 2. Create a...
1. Write an assembly language program that prompts the user for and reads four integers (x1,...
1. Write an assembly language program that prompts the user for and reads four integers (x1, y1, x2, y2) which represent the coordinates of two points. Make sure you keep track of which number is which. 2. Treat the line between the points as the radius of a sphere and compute the surface area of the sphere. Print the output with a label, such as “The surface area of the sphere is: …”. Hint: The distance between the points is...
Question Write a C program that asks the user to enter two integers x and n....
Question Write a C program that asks the user to enter two integers x and n. Then the program computes xn (=x * x * x …… (n times)) using for loop. and give me an output please use printf and scanf #include int main(void) {     //Declare required variables             //read two integers x , n from the keyboard                 //compute xn using for loop                     printf("< Your name >\n");...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT