Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Title: Arithmetic Choice
- //purpose: Techincally a calculator
- //Author: Robert Hewson
- #include "stdafx.h"
- #include <iostream>
- #include <conio.h>
- struct problem
- {
- double numone;
- double numtwo;
- char arithmetic;
- double answer;
- };
- using namespace std;
- int main()
- {
- problem problem1;
- cout<<"Please enter the first number."<<endl;
- cin>>problem1.numone;
- cout<<"Please enter the second number."<<endl;
- cin>>problem1.numtwo;
- cout<<"Please enter if you want to (a)dd, (s)ubtract, (d)ivide, or (m)ultiply"<<endl;
- cin>>problem1.arithmetic;
- if(problem1.arithmetic == 'a' )
- problem1.answer = problem1.numone + problem1.numtwo;
- cout<<"The answer is "<<problem1.answer;
- else
- {
- if(problem1.arithmetic == 's' )
- problem1.answer = problem1.numone - problem1.numtwo;
- cout<<problem1.answer<<endl;
- else
- {
- if(problem1.arithmetic == 'd' )
- problem1.answer = problem1.numone / problem1.numtwo;
- cout<<problem1.answer<<endl;
- else
- {
- if(problem1.arithmetic == 'm')
- problem1.answer = problem1.numone * problem1.numtwo;
- cout<<problem1.answer<<endl;
- }
- }
- }
- getch();
- }
Add Comment
Please, Sign In to add comment