expand icon
book C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith cover

C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith

Edition 8ISBN: 978-1285867410
book C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith cover

C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith

Edition 8ISBN: 978-1285867410
Exercise 15
Understanding if else Statements
In this exercise, you use what you have learned about writing if else statements in C++ to study a complete C++ program that uses if else statements. This program was written to calculate customer charges for a telephone company. The telephone company charges 25 cents per minute for calls outside of the customer's area code that last over 10 minutes. All other calls are 10 cents per minute. Take a few minutes to study the code that follows, and then answer Questions.
// Telephone.cpp - This program determines telephone call// charges.#include using namespace std;int main(){int custAC, custNumber;int calledAC, calledNumber;int callMinutes;double callCharge;const int MAX_MINS = 10;const double CHARGE_1 =.25;const double CHARGE_2 =.10;custAC = 847;custNumber = 5551234;calledAC = 630;calledNumber = 5557890;callMinutes = 50;if(calledAC != custAC callMinutes MAX_MINS)callCharge = callMinutes * CHARGE_1;elsecallCharge = callMinutes * CHARGE_2;cout ? "Customer Number: " ? custAC ? "-" ? custNumber? endl;cout ? "Called Number: " ? calledAC ? "-"? calledNumber ? endl;cout ? "The charge for this call is $" ? callCharge? endl;return 0;}
What is the exact output if the variable named calledAC is assigned the value 847 rather than the value 630?
Explanation
Verified
like image
like image

The if…else statement is also known as "...

close menu
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
cross icon