Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a simple scientific calculator program as follows 1 Display a menu of opt

ID: 3585273 • Letter: C

Question

Create a simple scientific calculator program as follows 1 Display a menu of options according to table. 2- Askthe userto enter a menu option (upper and lower case will work. 3- If menu option is not valid, display msg "invalid option" and repeat parts 1 and 2. (use do-while) 4- For "add" option ask the userto enter two numbers, store as double and display sum. 5- osubtract option ask the userto enter two numbers, store as double and display difference 6- For multiply option, same as above Fordivide option, same as above(test the denominator, if zero, display an appropriate msg). 8- For remainder option, ask the user to enter two integers and displays remainder 9- For squared, ask the user to input a number and output the square of the number 10- For square root, check if the number is negative and output appropriate msg. 11 For factorial, ask for a number an output factorial( 5!-5*43"2'1). (use for loop) 12- For is even, display msg indicating if number is even 13- For greater integer, round the number to an integer greater than number. 14- For less integer, round the number to an integer less than number Every time a calculation ends, the menu is re-displayed. The program will only exit when the user enters X

Explanation / Answer

Given below is the program with output. Since the table for menu is not given in the question, I have used 1, 2 , 3...

Hope the answer helped. If it did, please do rate it . Thank you.

#include <stdio.h>
#include <math.h>
int main()
{
double d1, d2; //2 double numbers
double dans; //double answer
int i1, i2; //2 int numbers
int ians; //int answer
int choice;
  
do
{
printf("1. Add ");
printf("2. Subtract ");
printf("3. Mulitply ");
printf("4. Divide ");
printf("5. Remainder ");
printf("6. Squared ");
printf("7. Squareroot ");
printf("8. Factorial ");
printf("9. Even ");
printf("10. Greater Integer ");
printf("11. Less Integer ");
printf("12. Exit ");
  
printf("Enter your choice: ");
scanf("%d", &choice);
printf(" ");
switch(choice)
{
case 1:
printf("Enter number1: ");
scanf("%lf", &d1);
printf("Enter number2: ");
scanf("%lf", &d2);
dans = d1 + d2;
printf("%lf + %lf = %lf ", d1, d2, dans);
break;
case 2:
printf("Enter number1: ");
scanf("%lf", &d1);
printf("Enter number2: ");
scanf("%lf", &d2);
dans = d1 - d2;
printf("%lf - %lf = %lf ", d1, d2, dans);
break;
case 3:
printf("Enter number1: ");
scanf("%lf", &d1);
printf("Enter number2: ");
scanf("%lf", &d2);
dans = d1 * d2;
printf("%lf * %lf = %lf ", d1, d2, dans);
break;
case 4:
printf("Enter number1: ");
scanf("%lf", &d1);
printf("Enter number2: ");
scanf("%lf", &d2);
if(d2 == 0)
printf("Division by zero attempted ");
else
{
dans = d1 / d2;
printf("%lf / %lf = %lf ", d1, d2, dans);
}
break;
case 5:
printf("Enter 2 integers to find remainder- ");
printf("Enter number1: ");
scanf("%d", &i1);
printf("Enter number2: ");
scanf("%d", &i2);
ians = i1 % i2;
printf("%d mod %d = %d ", i1, i2, ians);
break;
case 6:
printf("Enter a number to find square: ");
scanf("%lf" , &d1);
dans = d1 * d1;
printf("Square(%lf) = %lf ", d1, dans);
break;
case 7:
printf("Enter a number to find square root: ");
scanf("%lf" , &d1);
dans = sqrt(d1);
printf("sqrt(%lf) = %lf ", d1, dans);
break;
case 8:
printf("Enter an integer to find factorial:");
scanf("%d", &i1);
ians = 1;
for(i2 = 1; i2 <= i1; i2++)
ians = ians * i2;
printf("%d ! = %d ", i1, ians);
break;
case 9:
printf("Enter an integer to find if even:");
scanf("%d", &i1);
if(i1 %2 == 0)
printf("%d is even ", i1 );
else
printf("%d is NOT even ", i1 );
break;
case 10:
printf("Enter a real number to round to greater integer: ");
scanf("%lf", &d1);
i1 = ceil(d1);
printf("%lf rounded to greater integer is %d ", d1, i1);
  
break;
case 11:
printf("Enter a real number to round to lesser integer: ");
scanf("%lf", &d1);
i1 = floor(d1);
printf("%lf rounded to lesser integer is %d ", d1, i1);
break;
case 12:
break;
}
}while(choice != 12);
}

output

1. Add
2. Subtract
3. Mulitply
4. Divide
5. Remainder
6. Squared
7. Squareroot
8. Factorial
9. Even
10. Greater Integer
11. Less Integer
12. Exit
Enter your choice: 1

Enter number1: 3
Enter number2: 4
3.000000 + 4.000000 = 7.000000
1. Add
2. Subtract
3. Mulitply
4. Divide
5. Remainder
6. Squared
7. Squareroot
8. Factorial
9. Even
10. Greater Integer
11. Less Integer
12. Exit
Enter your choice: 2

Enter number1: 5
Enter number2: 6
5.000000 - 6.000000 = -1.000000
1. Add
2. Subtract
3. Mulitply
4. Divide
5. Remainder
6. Squared
7. Squareroot
8. Factorial
9. Even
10. Greater Integer
11. Less Integer
12. Exit
Enter your choice: 3

Enter number1: 4
Enter number2: 9
4.000000 * 9.000000 = 36.000000
1. Add
2. Subtract
3. Mulitply
4. Divide
5. Remainder
6. Squared
7. Squareroot
8. Factorial
9. Even
10. Greater Integer
11. Less Integer
12. Exit
Enter your choice: 4

Enter number1: 5
Enter number2: 2
5.000000 / 2.000000 = 2.500000
1. Add
2. Subtract
3. Mulitply
4. Divide
5. Remainder
6. Squared
7. Squareroot
8. Factorial
9. Even
10. Greater Integer
11. Less Integer
12. Exit
Enter your choice: 5

Enter 2 integers to find remainder-
Enter number1: 5
Enter number2: 3
5 mod 3 = 2
1. Add
2. Subtract
3. Mulitply
4. Divide
5. Remainder
6. Squared
7. Squareroot
8. Factorial
9. Even
10. Greater Integer
11. Less Integer
12. Exit
Enter your choice: 6

Enter a number to find square: 4
Square(4.000000) = 16.000000
1. Add
2. Subtract
3. Mulitply
4. Divide
5. Remainder
6. Squared
7. Squareroot
8. Factorial
9. Even
10. Greater Integer
11. Less Integer
12. Exit
Enter your choice: 7

Enter a number to find square root: 25
sqrt(25.000000) = 5.000000
1. Add
2. Subtract
3. Mulitply
4. Divide
5. Remainder
6. Squared
7. Squareroot
8. Factorial
9. Even
10. Greater Integer
11. Less Integer
12. Exit
Enter your choice: 8

Enter an integer to find factorial:5
5 ! = 120
1. Add
2. Subtract
3. Mulitply
4. Divide
5. Remainder
6. Squared
7. Squareroot
8. Factorial
9. Even
10. Greater Integer
11. Less Integer
12. Exit
Enter your choice: 9

Enter an integer to find if even:10
10 is even
1. Add
2. Subtract
3. Mulitply
4. Divide
5. Remainder
6. Squared
7. Squareroot
8. Factorial
9. Even
10. Greater Integer
11. Less Integer
12. Exit
Enter your choice: 10

Enter a real number to round to greater integer: 4.67
4.670000 rounded to greater integer is 5
1. Add
2. Subtract
3. Mulitply
4. Divide
5. Remainder
6. Squared
7. Squareroot
8. Factorial
9. Even
10. Greater Integer
11. Less Integer
12. Exit
Enter your choice: 11

Enter a real number to round to lesser integer: 3.44
3.440000 rounded to lesser integer is 3
1. Add
2. Subtract
3. Mulitply
4. Divide
5. Remainder
6. Squared
7. Squareroot
8. Factorial
9. Even
10. Greater Integer
11. Less Integer
12. Exit
Enter your choice: 12

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote