1. Engineering
  2. Computer Science
  3. serious people only follow example exactly also this is for...

Question: serious people only follow example exactly also this is for...

Question details


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: A or a or - Adds left and right operands. S or s or -- Subtracts right from left operand. 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 Result 30 ./lab3 Enter left operand: ZAMBY Invalid left operand ./lab3 Enter left operand: 22.17 Enter operation: & Unknown operation Restrictions 1. You must NOT duplicate any code. If you notice that youre writing the same statement, you need to rethink the flow of your code 2. You must use if statements to error check the users input, and you must use mutual exclusion where applicable (ie., else if and/or else). 3. You must use a SWITCH statement when determining which operation to perform Your default case must be used to determine if an invalid operation was specified 4. You may not call any functions (if you know how) 5. Comments and good formatting are required

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