Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can you please this coding / #include using namespace std; / / Global Constants const double HIGH _ SCHOOL _ DISCOUNT = 0 . 2

can you please this coding /#include
using namespace std;
// Global Constants
const double HIGH_SCHOOL_DISCOUNT =0.20;
const double SIX_OR_MORE_MONTHS_MEMBERSHIP_DISCOUNT =0.15;
const double FIVE_OR_MORE_INDIVIDUAL_LESSONS_DISCOUNT =0.20;
// Function Prototypes
void display_information();
void get_information(double& cost_per_month, double& cost_per_lesson, bool& is_high_school_student, int& num_months, int& num_lessons);
double calculate_membership_cost(double cost_per_month, double cost_per_lesson, bool is_high_school_student, int num_months, int num_lessons);
// Main Program
int main(){
// Declare variables
double cost_per_month, cost_per_lesson, membership_cost;
bool is_high_school_student;
int num_months, num_lessons;
// Call functions
display_information();
get_information(cost_per_month, cost_per_lesson, is_high_school_student, num_months, num_lessons);
membership_cost = calculate_membership_cost(cost_per_month, cost_per_lesson, is_high_school_student, num_months, num_lessons);
// Display membership cost
cout << "Membership cost: "<< membership_cost << endl;
return 0;
}
// Function Definitions
void display_information(){
// Display general information about LearnIt and its discounts
cout << "Welcome to LearnIt! We offer discounts for high school students, long-term memberships, and bulk lesson purchases." << endl;
}
void get_information(double& cost_per_month, double& cost_per_lesson, bool& is_high_school_student, int& num_months, int& num_lessons){
// Prompt the user and input: cost per month, cost per lesson, whether the student is in high school, number of months being purchased, number of lessons being purchased
cout << "Enter cost per month: ";
cin >> cost_per_month;
cout << "Enter cost per lesson: ";
cin >> cost_per_lesson;
cout << "Are you a high school student? (1 for yes, 0 for no): ";
cin >> is_high_school_student;
cout << "Enter number of months being purchased: ";
cin >> num_months;
cout << "Enter number of lessons being purchased: ";
cin >> num_lessons;
}
double calculate_membership_cost(double cost_per_month, double cost_per_lesson, bool is_high_school_student, int num_months, int num_lessons){
// Calculate and return the final membership cost
double total_cost =(cost_per_month * num_months)+(cost_per_lesson * num_lessons);
if (is_high_school_student){
total_cost *=(1- HIGH_SCHOOL_DISCOUNT);
}
if (num_months >=6){
total_cost *=(1- SIX_OR_MORE_MONTHS_MEMBERSHIP_DISCOUNT);
}
if (num_lessons >=5){
total_cost *=(1- FIVE_OR_MORE_INDIVIDUAL_LESSONS_DISCOUNT);
}
return total_cost;
}
//Added #include to include the necessary header for input/output operations.
//Added using namespace std; to avoid needing to prepend std::to standard library functions like cout and cin.
//Changed print() to cout << for outputting the membership cost.
//Added const keyword before the global constant declarations.

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

Climate And Environmental Database Systems

Authors: Michael Lautenschlager ,Manfred Reinke

1st Edition

1461368332, 978-1461368335

More Books

Students also viewed these Databases questions

Question

What steps should be taken to address any undesirable phenomena?

Answered: 1 week ago