1. Engineering
  2. Computer Science
  3. urgent please help serious people only i am writing a...

Question: urgent please help serious people only i am writing a...

Question details

URGENT PLEASE HELP!!!!!

SERIOUS PEOPLE ONLY!!! I am writing a program using C++ for my computer science course and basically what we have to do is make a "simple calculator". And my program compiles and everything but the "logic" is all messed up. Like what happens is it'll ask me to type in one number but actually want me to type in multiple numbers and then it does some weird operation that gives me a crazy number. But anyways please help fix my code, please and thank you. My assignment and code and output will be attached. Also you need to follow the example EXACTLY.

Assignment You will be creating a calculator that allows the user to enter two operands and an operation. Your program will then give the result. Operands The operands will be specified as real numbers, so you must declare the appropriate data types. If your program is unable to input valid data from the user, output the following error prompt: Invalid left operand. or Invalid right operand Every operation will require two operands. Operations The operation will be specified as a single character, however the user may enter more than one character (see examples below) The following operations are performed for the given characters: - Adds left and right operands. - Subtracts right from left operand. A or a or+ Sor s or - M or m or x or *- Multiplies left and right operands D or d or / - Divides left over right operand. If the user does not specify one of the above operands, output the following error prompt: Unknown operation.Examples ./Lab3 Enter left operand: 10 Enter operation: * Enter right operand: 3 Result30 Enter left operand: ZAMBY Invalid left operand. ./lab3 Enter left operand: 22.17 Enter operation: & Unknown operation.include <iostreato using namespace std; int main O double left, right; char operation; cout <Enter left operand:; cin Left; if CICcin > left) cerr <<Not a real number. n return cout << Enter operation: cin operation; switch Coperation) case a case A leftright; break; Case m case M left *= right; break; default: cerr << Invalid Lnput. In return 1 cout << Enter right operand: cin > right; if ((cin right)) cerr Not a real number. In return 2; cout <Result-leftn return8Enter left operand: 9 Enter operation: a Enter right operand: 1 4 Result 2.07363e-317.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution