Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ANSWER IN C++ Project 1 - Calculator Description For this project, you are required to build a simple calculator simulator in C++. You are required

ANSWER IN C++

Project 1 - Calculator

Description

For this project, you are required to build a simple calculator simulator in C++.

You are required to implement all operations (explained in this document) as separate functions. Each function will be responsible for one mathematical operation. C++ has a very convenient mathematical library, but unfortunately you cannot use it. So, you need to write your own function for each operation. The code for the functions that implement root, power, LCM (least common multiple), and GCD (great common divisor) is given at the end of this document. You are ALLOWED to copy and paste those functions into your project and use them.

The user must choose which operation she/he will perform based on a menu option displayed. Once an operation is selected and performed the program should again display the menu. This shall happen until the user selects the quit option. It is required to display a welcome message when the program starts and exit message when exiting. Both must be implemented as functions that return the messages as strings. If no correct menu option is selected the user will be asked for a valid input until they do so.

Operations: addition, subtraction, multiplication, division, roota, powerb, percentagec, least common multipled, greatest common divisord and modulus;

a = The user must specify the number and the nth-root desired: see algorithm in the end of this document.

b = the user must specify the exponent an , where a and n will be provided by the user, and must be positive

c = in the format of X% of N, where N is a number and X the requested percentage of that number (It is up to you how to handle the input, as long it is correct)

d= assume that these operations work only with positive integers

The next page shows an example of menu and execution shown to the user.

----------------------------------------------------------------------

WELCOME TO THE CALCULATOR PROJECT

----------------------------------------------------------------------

A.) Addition

B.) Subtraction

C.) Multiplication

D.) Division

E.) Roots (only positive number)

F.) Power (only positive number)

G.) Percentage

H.) Least Common Multiplier

I.) Greatest Common Divisor

J.) Modulus

K.) Display function execution*

L.) Quit

----------------------------------------------------------------------

Please select an operation: A

Please provide the first number: 2

Please provide the second number: 3

Operation: 2 + 3 = 5

----------------------------------------------------------------------

WELCOME TO THE CALCULATOR PROJECT

----------------------------------------------------------------------

A.) Addition

B.) Subtraction

C.) Multiplication

D.) Division

E.) Roots (only positive number)

F.) Power (only positive number)

G.) Percentage

H.) Least Common Multiplier

I.) Greatest Common Divisor

J.) Modulus

K.) Display function execution*

L.) Quit

----------------------------------------------------------------------

Please select an operation:

Constraints:

Root/Power operations shall not work with negative numbers the user must be notified of that and ask for a new input until a proper one is provided.

Division - there is no division by 0 (zero) the user must be notified of that and ask for a new input.

All the operations, except where specified, must work for any Real number.

Every function (including main) must contain: Author name, creation date, last modification date, purpose (standard comment headers).

DO NOT use math libraries (e.g. math.h, cmath) This will result in a 75% penalty.

Required Test Cases: minimum 20 cases + Menu:

Addition (2)

Subtraction (2)

Multiplication (2)

Division (2 one must handle 0 as input in b for a/b)

Root (2)

Percentage (2)

Exponent (2)

LCM (2)

GCD (2)

Modulus (2)

Welcome

Exit

No global variables are allowed except constants

Only functions main, menu, and display menu execution option may have any input or output statements.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Distributed Relational Database Architecture Connectivity Guide

Authors: Teresa Hopper

4th Edition

0133983064, 978-0133983067

More Books

Students also viewed these Databases questions

Question

7. It is advisable to do favors for people whenever possible.

Answered: 1 week ago