Lab 6 Exercise: switch / if Marks: 2 Design a simple calculator using (if AND switch). Use an if condition to determine
Posted: Thu Jul 14, 2022 2:17 pm
Lab 6 Exercise: switch / if Marks: 2 Design a simple calculator using (if AND switch). Use an if condition to determine if the user would like to enter the calculator or not. The calculator can ONLY be accessed if the user enters the characters Y or y. If the calculator is accessed, the program will then prompt the user to enter 2 numbers to be stored in variables num1 and num2. Use a switch statement to prompt the user to choose a desired mathematical operation (+,−,∗,/). The program will preform the operation and display the results (to 2 decimal points ONLY). If the user enters the wrong mathematical operation, the program will prompt the user the following message: "You have entered the wrong choice." Output example if the characters ' Y ' or ' Y ' is entered Would you like to use a simple calculator? Enter Y for yes or N to exit program: Y Enter the first number: 2 Enter the second number: 5 Choose an operation: <+,−,⋆,/>>:+ 2.00+5.00=7.00 Thank you, exiting program Output example if the characters ' ′ ' is entered Would you like to use a simple calculator? Enter Y for yes or N to exit program: N Thank you, exiting program