Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions dynacalc1.0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include<string>

using namespace std;

void newCalc();
float num1, num2, result;

string userInput;
Expand Down Expand Up @@ -36,13 +36,25 @@ int main()

if(userInput!= "+" && userInput!= "-" && userInput!= "*" && userInput!= "/")
{
cerr << "invalid input";
cerr << "invalid input" <<endl;
newCalc();
}

else
{
cout << num1 << userInput << num2 << " equals: " << result << ".\n";
cout << num1 << userInput << num2 << " equals: " << result << endl;
newCalc();
}

return 0;
}
void newCalc()
{
char newOption;
cout << "Do you to make a new calculation? (y/n) " <<endl;
cin >> newOption;
if(newOption == 'y' || newOption == 'Y')
main();
else
return;
}