
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
النسخة 8الرقم المعياري الدولي: 978-1285867410
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
النسخة 8الرقم المعياري الدولي: 978-1285867410 تمرين 14
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 expression in the if statement is changed to callMinutes = MAX_MINS?
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 expression in the if statement is changed to callMinutes = MAX_MINS?
التوضيح
The if…else statement is also known as "...
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
لماذا لم يعجبك هذا التمرين؟
أخرى 8 أحرف كحد أدنى و 255 حرفاً كحد أقصى
حرف 255