## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

Problem Description Students at a local elementary school that you have been tutoring are having some difficulty with some mathematical concepts they are learning in their math class. You have decided to write a simple computer program that will help with a few of these concepts. Program Directions Write a C++ program that uses the information found in the formula section to help students to practice their math skills. The program must do the following: • Ask the user to input the two numbers. • Ask the user to select the mathematical operator. o Note if the user inputs a real value to use with the modulus operator, alert the user that the real value inputted cannot be used with the modulus operator. • Ask the user for the answer. • Calculate the correct answer using the input of the numbers and the math operator. • Display to the screen the correct answer as calculated by the formula and a statement telling the user if he/she was correct. • Allow the user to continue with the program until he/she no longer wants to continue to use the program. The program should take both upper and lower case input. Formulas + * / % MATHEMATICAL OPERATORS Addition Subtraction Multiplication Division Modulus

Program Output The program should display the following: • A question asking the user if he/she wants to begin using the program and continue using the program • A menu displaying the operator selection choices • The correct answers as calculated by the formulas • A statement if the answer is correct or incorrect • An alert that the modulus cannot be used with real values. Program Calculations Failure to include the formulas in the program will result in a deduction of points on the assignment. Program Header Information • Name • Program number • Collaboration statement • The answers to the following question: o What is the purpose of the program? o What is the input? (Is there any?) o What is the output? Sample Run Below is a sample run. DO NOT include additional input or output streams in your program.

/* Adonis Brown Program 2 I worked on the assignment by myself and received no additional assistance. 1. The purpose of this program is to accept numbers from the user, then succesfully perform the operation that they have selected upon the numbers. It also allows them to continue as long as they are willing. 2. The inputs are one input to start and continue the program, 2 numbers, and one input for the operator of the user's liking. 3. The outputs are many. The user is asked if they want to begin. The user is then asked for two numbers and their preferred operator. If the user inputs numbers, and the program performs operations upon them, the user is asked to input their answer to the operation. The program then informs the user if they are correct or incorrect. If during the operator selection process the modulous is selected, and either or both of the numbers are real, the computer informs the user of this and requests that the user selects a different number (or numbers) for usage with the modulous. After this, the program continues as usual. */ #include <iostream.h> #include <stdlib.h> #include <string> int main() { double num1, num2, u_ans, p_ans = 0; char oper, redo; cout<<"Enter 'Y' if you would like to begin."<<endl; cin>>redo; while ((redo == 'Y')||(redo == 'y')) { cout<<"Please enter 2 numbers: "; cin>>num1>>num2; cout<<endl<<"Please select your mathematical operator."<<endl; cout<<endl<<"+ = Addition"<<endl<<"- = Subtraction"<<endl<< "* = Multiplication"<<endl<<"/ = Division"<<endl <<"% = Modulous Division (Provides the remainder)"<<endl<<endl; cin>>oper; cout<<endl; while (oper == '%') { if ((oper == '%')&&(num1 != int(num1))&&(num2 != int(num2))) { cout<<num1<<" and "<<num2<<" are real numbers and cannot be used with modulous"<<endl; cout<<"Please re-enter non-real values: "; cin>>num1>>num2; }

else if (oper == '%') { if ((oper == '%')&&(num1 != int(num1))) { cout<<num1<<" is a real number and cannot be used with modulous."<<endl <<endl; cout<<"Please enter a non-real value for your first number: "; cin>>num1; break; } if ((oper == '%')&&(num2 != int(num2))) { cout<<num2<<" is a real number and cannot be used with modulous."<<endl <<endl; cout<<"Please enter a non-real value for your second number: "; cin>>num2; break; } } else break; } while ((oper != '+')&&(oper != '-')&&(oper != '/')&&(oper != '*')&&(oper != '%')) { cout<<"Invalid Entry!"<<endl<<"Enter a new operator: "; cin>>oper; } cout<<endl; switch(oper) { case '+': p_ans = num1 + num2; break; case '-': p_ans = num1 - num2; break; case '*': p_ans = num1 * num2; break; case '/': p_ans = num1 / num2; break; case '%': p_ans = int(num1) % int(num2); break; default: cout<<"Invalid Entry!"<<endl; break; } cout<<"Please enter your answer."<<endl<<endl<<"(Your answer)"<<endl<< num1<<" "<<oper<<" "<<num2<<" = "; cin>>u_ans;

cout<<endl; if (u_ans == p_ans) cout<<"(Program answer)"<<endl<<num1<<" "<<oper<<" "<<num2<<" = "<< p_ans<<endl<<"You got it right!"<<endl<<endl; else cout<<"(Program answer)"<<endl<<num1<<" "<<oper<<" "<<num2<<" = "<< p_ans<<endl<<"Try again."<<endl<<endl; cout<<"Enter 'Y' to continue. "; cin>>redo; cout<<endl; } system("PAUSE"); return 0; }

- Mid Term1 Solutionuploaded byMuneeb Hassan Soomro
- Sbi Po Marketing Aptitude Postsuploaded bysuresha90
- d912f50929de42ee4euploaded byMuhammad Mirza
- 33946329 ISTQB Advanced Study Guide 3uploaded bylistarlaura
- PLC Scanuploaded bymoney_kandan2004
- C1.1_Introduction_to_OSuploaded byMd Nazirul Azim Roslim
- PLC Programminguploaded byAhmet Taş
- SI-E124.pdfuploaded byMAZEN
- EN_ACS880_Drive_appl_prg_UM_D_A4.pdfuploaded byIancu Constantin
- Lec1uploaded byMUhammad Zia
- STEP 7 V5.2 Getting Starteduploaded byAlejandro Zanella
- What is Ict1uploaded bygfhfhf
- course_planuploaded byfaskinan
- A. H. Deliormanli & T. Onargan Rock Mass Classification Using a Computer Program-Classmass (2)uploaded byAze
- Vemulapati_Application Linking and Enabling - IDOC Communicationuploaded bySudeep Vemulapati
- Mach4 Operation Manual.pdfuploaded bymarcos
- SIEMENS Programminguploaded byMario Wolfie Guevara
- Chp2 Slideuploaded byJackYuan JinFeng
- The Engineering Design Revolution - CAD History - 05 Civil Engineeringuploaded byphamduyproject
- Microprocessor 8085 Unit1uploaded byRishabh Maithani
- Computer Assignment 3uploaded bySaba Nafees
- Statics - Truss Problem_2uploaded byalp
- PC AT Technical Reference Mar84 3 of 3uploaded bykgrhoads
- 1756-XXXX ControlLogix Digital I-O Modulesuploaded bydaovanthanh_bk2007
- Chapter 1 Introductioncuploaded byimraan37
- Automatic Graphical Design Generatoruploaded byAnonymous kw8Yrp0R5r
- Synopsis of KBC Gameuploaded byAkaShGrOver
- CHAP_7.1uploaded byDjokata
- Emerson Climate Technologies E2 Inst Opuploaded byPatrick
- YEARLYPLANF1uploaded byNazirah Md Noor

Read Free for 30 Days

Cancel anytime.

Close Dialog## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

Loading