Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!