I have been assiged to do a calculator project that :
Prompt the user for numbers (floating point)
Prompt the user for functions (add, subtract, multiply, divide).
Keep prompting for numbers and functions and display the running total.
Keep prompting until the user enters "equals" (= sign).
Prompt the user to do another calculation or quit the program.
I have written a code for a calculator that works but doesnt do all of the following (made it to simple), here is the code: should i start over or can i tweek this code to make it do all of the following?
#include <iostream>
using namespace std; // so we dont have to use std anymore
int main () // start of function
{
char another;
char op; // operator
double num1; // first number
double num2; // second number
Start:
system ("cls") ;
cout<< "welocome to my calculator\n"; // welcome screen
cout << "enter your first number\n"; // user enters first number
cin >> num1; // input first number
cout << "thank you\n"; // confirm users first number
cout << "now enter an operator ( +, -, *, or / ) \n"; // user enters operator
cin >> op; // inout operator
cout << "thank you\n"; // confirm users operator
cout << "enter your second number\n"; // user enters second number
cin >> num2; // input second number
cout << "thank you\n"; // cofnfirm users second number
// begin switch
switch ( op )
{ case '+' : cout<< "your answer is " << num1 + num2 << endl;
break; // addition
case '-': cout<< " your answer is " << num1 - num2 << endl;
break; // subtration
case '*': cout<< " your answer is " << num1 * num2 << endl;
break; // mutilpication
It doesnt keep a running total and keep prompting the user until an equal sign is entered. I know there has to be some way to just run some sort of loop in my current code, but i just cant seem to figure it out