Question: Add an additional calculation to the calculator. This calculation should sum all of the integers between the two numbers the user entered (truncating the numbers

Add an additional calculation to the calculator. This calculation should sum all of the integers between the two numbers the user entered (truncating the numbers if the user entered a decimal). For example, if the user entered 5.2 and 8.7 then the calculator should sum all of the values between 5 and 8 (i.e. 5 + 6 + 7 + 8). Remember that if you store a double value in an int variable it is automatically truncated.

#include

using namespace std;

int main() {

// your code goes here

double operend1;

double operend2;

int operation;

cout <<" ";

cout<<"welcome to the simple calculator program. ";

cout<< "Enter the two real value and then select the mathematical operation apply to them. ";

while(true){

cout<<"Enter the first value : ";

cin>>operend1;

cout<<"Enter the second value : ";

cin>>operend2;

cout<<"Enter the operation(1-add, 2-subtract, 3-multiply, 4-divide, 5 - for sum of all integer between two given numbers) : ";

cin>>operation;

if(operation<1 || operation>5){

cout<<"Invalid operation";

continue;

}

switch(operation){

case 1 : cout<

cout<<" ";

break;

case 2 : cout<

cout<<" ";

break;

case 3 : cout<

cout<<" ";

break;

case 4 : cout<

cout<<" ";

break;

case 5 : int sum=0;

for(int i=operend1; i<=operend2; i++)

sum+=i;

cout<

cout<<" ";

}

int n;

cout<<"do u want to continue? enter 0 to no and 1 for yes : ";

cin>>n;

if(n==1)

continue;

else

break;

}

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!