Create the equivalent of a four-function calculator the


Object Oriented Programming

Assignment

Q1: Assuming there are 7.481 gallons in a cubic foot, write a program that asks the user to enter a number of gallons, and then displays the equivalent in cubic feet.

Q2: You can convert temperature from degrees Celsius to degrees Fahrenheit by multiplying by 9/5 and adding 32. Write a program that allows the user to enter a floating-point number representing degrees Celsius, and then displays the corresponding degrees Fahrenheit.

Q3: Create the equivalent of a four-function calculator. The program should ask the user to enter a number, an operator, and another number. (Use floating point.) It should then carry out the specified arithmetical operation: adding, subtracting, multiplying, or dividing the two numbers. Use a switch statement to select the operation. Finally, display the result. When it finishes the calculation, the program should ask whether the user wants to do another calculation. The response can be ‘y' or ‘n'. Some sample interaction with the program might look like this:

Enter first number, operator, second number: 10 / 3 Answer = 3.333333
Do another (y/n)? y
Enter first number, operator, second number: 12 + 100 Answer = 112
Do another (y/n)? n

Q4: Write a program that declares a variable that can hold the letter grade a student will receive in this class. Prompt the user to enter the letter. Then read it in, and echo it with explanation.

Q5:  What is the output after executing the following segment of code? int num = 10;
if (num > 10)
cout << "Yes" << endl; else
cout << "No" << endl;

a) Yes
b) Yes and No

c) No
d) Nothing

Q6: What is the output after executing the following segment of code?

int num = 5; if(num < 4)

cout << "Red" << endl; else
if(num < 10)
cout << "Yellow" << endl; else
cout << "Green" << endl;

a) Red
b) Green

c) Yellow
d) Two of the above

Q7: What is the output of the following code segment?

int x = 3; int y = 6;
if(x < 0 && y = 2) x = 40;
cout << x << " " << y << endl;

a) 3 6    c) 40 6

b) 3 2     d) 40 2

Q8: Write a program for a furniture company. Ask the user to choose P for pine, O for oak, or M for mahogany. Show the price of a table manufactured with the chosen wood. Pine tables cost $100, oak tables cost $225, and mahogany tables cost $310.

Q9: Write a program that asks the user to type a vowel from the keyboard. If the character entered is a vowel, display "OK"; if it is not a vowel, display an error message. Be sure to allow both uppercase and lowercase vowels. For this exercise, assume y is not a vowel.

Q10: Identify the error in the following program. vinclude

void main()

{

int i = 0;
i = i 1;
cout c< i « II
/comment\*  i + 1; cout cc i;
}

b.) #include
void main()

{
short 1-2500, j-3000;
cout » "i + j • m ›, -(i+j);

}

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Create the equivalent of a four-function calculator the
Reference No:- TGS01596118

Expected delivery within 24 Hours