
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 تمرين 16
Understanding Nested if Statements
In this exercise, you use what you have learned about writing nested if statements. This program was written for the Woof Wash dog-grooming business to calculate a total charge for services rendered. Woof Wash charges $12 for a bath, $10 for a trim cut, and $7 to clip nails. Take a few minutes to study the code that follows, and then answer Questions.
// WoofWash.cpp - This program determines if a doggy// service is provided and prints the charge.#include #include using namespace std;int main(){string service;const string SERVICE_1 = "bath";const string SERVICE_2 = "cut";const string SERVICE_3 = "trim nails";double charge;const double BATH_CHARGE = 12.00;const double CUT_CHARGE = 10.00;const double NAIL_CHARGE = 7.00;cout ? "Enter service: ";cin ? service;if(service == SERVICE_1)charge = BATH_CHARGE;else if(service == SERVICE_2)charge = CUT_CHARGE;else if(service == SERVICE_3)charge = NAIL_CHARGE;elsecharge = 0.00;if(charge 0.00)cout ? "The charge for a doggy " ? service ? " is $"? charge ? endl;elsecout ? "We do not perform the " ? service? " service." ? endl;return 0;}
What is the exact output when this program executes if the user enters "bath"?
In this exercise, you use what you have learned about writing nested if statements. This program was written for the Woof Wash dog-grooming business to calculate a total charge for services rendered. Woof Wash charges $12 for a bath, $10 for a trim cut, and $7 to clip nails. Take a few minutes to study the code that follows, and then answer Questions.
// WoofWash.cpp - This program determines if a doggy// service is provided and prints the charge.#include #include using namespace std;int main(){string service;const string SERVICE_1 = "bath";const string SERVICE_2 = "cut";const string SERVICE_3 = "trim nails";double charge;const double BATH_CHARGE = 12.00;const double CUT_CHARGE = 10.00;const double NAIL_CHARGE = 7.00;cout ? "Enter service: ";cin ? service;if(service == SERVICE_1)charge = BATH_CHARGE;else if(service == SERVICE_2)charge = CUT_CHARGE;else if(service == SERVICE_3)charge = NAIL_CHARGE;elsecharge = 0.00;if(charge 0.00)cout ? "The charge for a doggy " ? service ? " is $"? charge ? endl;elsecout ? "We do not perform the " ? service? " service." ? endl;return 0;}
What is the exact output when this program executes if the user enters "bath"?
التوضيح
The nested if statement helps to creates...
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
لماذا لم يعجبك هذا التمرين؟
أخرى 8 أحرف كحد أدنى و 255 حرفاً كحد أقصى
حرف 255