Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include<string>
- using namespace std;
- int main()
- {
- double Num1;
- double Num2;
- int Operation;
- int Reply;
- double Result;
- cout << " \t \t \t \t welcome to Calculator\t \t \t \t " << endl;
- startingpoint:
- //TAKE THE INPUT FROM USER //
- cout << "please enter two numbers \n" << endl;
- cin >> Num1 >> Num2;
- //CHECK THE VALIDATE OF NUMBERS//
- if (cin.fail())
- {
- cin.clear();
- cin.ignore(10000, '\n');
- goto startingpoint;
- }
- // TAKE THE OPERATION FROM USER//
- chooseOperation:
- cout << "please enter 1 for + , 2 for - , 3 for * , 4 for / , 5 to enter other numbers" << endl;
- cin >> Operation;
- //RE ENTER THE TWO NUMBERS//
- if (cin.fail())
- {
- cout << "please select validate operation" << endl;
- cin.clear();
- cin.ignore(10000, '\n');
- goto chooseOperation;
- }
- else if (Operation == 1)
- {
- Result = Num1 + Num2;
- }
- else if (Operation == 2)
- {
- Result = Num1 - Num2;
- }
- else if (Operation == 3)
- {
- Result = Num1 * Num2;
- }
- else if (Operation == 4)
- {
- if (Num2 == 0)
- {
- cout << "Can't divide over zero \n" << endl;
- goto chooseOperation;
- }
- else
- {
- Result = Num1 / Num2;
- }
- }
- else if (Operation == 5)
- {
- goto startingpoint;
- }
- //OUR OUTPUT//
- cout << "The Result is " << Result << endl;
- // MAKE OFFER FOR USER
- cout << " if you want to calculate other two numbers enter zero" << endl;
- cin >> Reply;
- if (Reply == 0)
- {
- goto startingpoint;
- }
- else {
- cout << "Thank's for using our software \n";
- }
- system("pause");
- }
Add Comment
Please, Sign In to add comment