Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ // Program AddSub reads in a letter (A or S) and two int values. // If the letter is A, the two values are

C++
// Program AddSub reads in a letter (A or S) and two int values.
// If the letter is A, the two values are added.
// If the letter is S, the second is subtracted from the first.
// The answer is printed appropriately labeled.
#include
using namespace std;
int main ()
{
char operatorCode;
int value1;
int value2;
int answer;
cout
cout
cout
cin >> operatorCode;
cin >> value1 >> value2;
if (operatorCode = 'A')
{
answer = value1 + value2;
cout
}
else
answer = value1 - value2;
cout
return 0;
}
image text in transcribed
Exercise 1: Program AddSub is supposed to read in a letter and two integer values and print elther the sum of the two values or the difference of the two values depending on the letter read. It is such a simple program, but it doesn't even compile! Correct the program and describe the errors. Exercise 2: Now that the program compiles, run it with the following sets of values. Input Values A 10 20 A 20 10 S 10 20 s 20 10 Means What Is Printed Add 10 to 20 Add 20 to 10 Subtract 20 from 10 Subtract 10 from 20 Exercise 3: Unless you corrected the logic errors in Exercise 1, your answers are incorrect. Locate the logic errors and rerun your program until you get the correct answers. Describe the errors

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions

Question

1. Identify three approaches to culture.

Answered: 1 week ago

Question

3. Identify and describe nine cultural value orientations.

Answered: 1 week ago

Question

4. Describe how cultural values influence communication.

Answered: 1 week ago