Write a program that will simulate a simple calculator. There will be four options: add two numbers, subtract two numbers, square root and raise to the power. During the subtraction option, you should not get any negative numbers when subtracting. For example, if we subtract 4 -7 you should get 3 not negative 3. Tip: use the absolute value function. You will use a switch case statement to create the selection mechanism. You will use three predefined functions we have used from chapter 4. The program will loop as long as the user types in Y or y for yes. You must include comments, failure to do so will vastly affect your grade. Once you are done, submit in a .cpp file. You do not need to show me the running program. I will check to see that it runs as l am grading your lab. Select a an option (1-4) from the following 2. subtraction of two positive numbers 1. Addition of two number 3. Square root of a number 4. Raise to the power 1 You chose to add two number Enter the first number 2 Enter the second number The addition of the two numbers is 4 Do you want to run this program again? This program functions as a small calculator Select a an option (1-4) from the following 1. Addition of two number 2. subtraction of two positive numbers 3. Square root of a number 4. Raise to the power You chose 2 to subtract two positive numbers Enter the first number 4 Enter the second number 5 The subtraction of these two numbers is Do you want to run this program again?

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Write a program that will simulate a simple calculator. There will be four options: add two numbers,
subtract two numbers, square root and raise to the power. During the subtraction option, you should
not get any negative numbers when subtracting. For example, if we subtract 4 -7 you should get 3 not
negative 3. Tip: use the absolute value function. You will use a switch case statement to create the
selection mechanism. You will use three predefined functions we have used from chapter 4. The
program will loop as long as the user types in Y or y for yes. You must include comments, failure to do
so will vastly affect your grade. Once you are done, submit in a .cpp file. You do not need to show me
the running program. I will check to see that it runs as l am grading your lab.
Select a an option (1-4) from the following
1. Addition of two number
2. subtraction of two positive numbers
3. Square root of a number
4. Raise to the power
1
You chose to add two number
Enter the first number
2
Enter the second number
2
The addition of the two numbers is 4
Do you want to run this program again?
y
This program functions as a small calculator
Select a an option (1-4) from the following
1. Addition of two number
2. subtraction of two positive numbers
3. Square root of a number
4. Raise to the power
2
You chose 2 to subtract two positive numbers
Enter the first number
4
Enter the second number
5
The subtraction of these two numbers is
Do you want to run this program again?
Transcribed Image Text:Write a program that will simulate a simple calculator. There will be four options: add two numbers, subtract two numbers, square root and raise to the power. During the subtraction option, you should not get any negative numbers when subtracting. For example, if we subtract 4 -7 you should get 3 not negative 3. Tip: use the absolute value function. You will use a switch case statement to create the selection mechanism. You will use three predefined functions we have used from chapter 4. The program will loop as long as the user types in Y or y for yes. You must include comments, failure to do so will vastly affect your grade. Once you are done, submit in a .cpp file. You do not need to show me the running program. I will check to see that it runs as l am grading your lab. Select a an option (1-4) from the following 1. Addition of two number 2. subtraction of two positive numbers 3. Square root of a number 4. Raise to the power 1 You chose to add two number Enter the first number 2 Enter the second number 2 The addition of the two numbers is 4 Do you want to run this program again? y This program functions as a small calculator Select a an option (1-4) from the following 1. Addition of two number 2. subtraction of two positive numbers 3. Square root of a number 4. Raise to the power 2 You chose 2 to subtract two positive numbers Enter the first number 4 Enter the second number 5 The subtraction of these two numbers is Do you want to run this program again?
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education