Question: Every line in this code please explain (c++ program). #include #include #include int main() { // declaring variables of float datatype to hold various types

Every line in this code please explain (c++ program).

#include

#include

#include

int main()

{

// declaring variables of float datatype to hold various types of fees

float units, labSubjects, discount, tuitionFee, labFee;

float miscFee, totalFee, discountFee, discountedFee;

// declaring variable of char datatype to hold the choice of user regarding

// payment through cash or installment

char choice;

// prompt user to enter number of units

printf("Enter number of units: ");

// read the number of units entered by the user

scanf("%f", &units);

// prompt user to enter number of laboratory subjects

printf("How many subjects with Lab?: ");

// read the number of laboratory subjects entered by the user

scanf("%f", &labSubjects);

// prompt user to enter percentage of discount

printf("How Many Percent of discount?: ");

// read the percentage of discount entered by the user

scanf("%f", &discount);

// calculate the tuition fee = 23 x 869.6/unit = number of units * 869.6/unit

tuitionFee = units * 869.6;

// calculate the lab fee = 2 x 750/unit = number of laboratory subjects * 750/subject

labFee = labSubjects * 750.0;

// miscellaneous fee is fixed = 3300

miscFee = 3300.0;

// calculate total fee = tuition fee + laboratory fee + miscellaneous fee

totalFee = tuitionFee + labFee + miscFee;

// calculate the discount fee = discounts/scholarships =

// = 25% of tuition fee = tuition fee x percentage of discount/100

discountFee = tuitionFee * discount/100;

// calculate the total fee after discount

discountedFee = totalFee - discountFee;

// display the fee details

printf("Tuition Fee: %.2f", tuitionFee);

printf(" Laboratory Fee: %.2f", labFee);

printf(" Micellanneous Fee: %.2f", miscFee);

printf(" Total Assessment: %.2f", totalFee);

// prompt user to enter his choice for payment through cash or payment through installment

// user has to enter characters 'c' or 'i' or 'C' or 'I'

printf(" Press [C] for cash");

printf(" Press [I] for installment");

// read the user's choice for payment

printf(" Enter your choice: ");

fflush(stdin);

scanf(" %c", &choice);

// convert the choice character into lowercase

choice = tolower(choice);

// using switch statment

switch(choice)

{

// if the user has chosen payment through cash

// display the bill

case 'c': printf("Summary");

printf(" Current Assessment : %.2f", totalFee);

printf(" Discount/Scholarship : %.2f", discountFee);

printf(" Previous Balance : 00.00");

printf(" Current Receivable : %.2f", discountedFee);

break;

// if the user has chosen payment through installment

// calculate installment amounts and display the bill

// down payment = 20% of discounted fee rounded to nearest 100's

// prelim payment = 40% of remaining discounted fee

// midtem payment = 40% of remaining discounted fee

// final payment = remaining discounted fee

case 'i': int down, prelim, midtem;

float finals;

down = discountedFee * 0.2;

if(down % 100 != 0)

down = ceil(down/100.0)*100.0;

prelim = (discountedFee - down) * 0.4;

midtem = (discountedFee - down) * 0.4;

finals = discountedFee - down - prelim - midtem;

printf("Down : %d", down);

printf(" Prelim : %d", prelim);

printf(" Midtem : %d", midtem);

printf(" Finals : %.2f", finals);

break;

}

return 0;

}

This is an outputEvery line in this code please explain (c++ program). #include #include #include

int main() { // declaring variables of float datatype to hold various

Output Clear /tmp/REOC5TBI05.0 Enter number of units: 23 How many subjects with Lab?: 2 How Many Percent of discount?: 50 Tuition Fee: 20000.80 Laboratory Fee: 1500.00 Micellanneous Fee: 3300.00 Total Assessment: 24800.80 Press [C] for cash Press [I] for installment Enter your choice: C Summary Current Assessment Discount/Scholarship Previous Balance Current Receivable . 24800.80 10000.40 00.00 14800.40 : Output Clear /tmp/REOC5TBIQ5.0 Enter number of units: 23 How many subjects with Lab?: 2 How Many Percent of discount?: 50 Tuition Fee: 20000.80 Laboratory Fee: 1500.00 Micellanneous Fee: 3300.00 Total Assessment: 24800.80 Press [C] for cash Press [I] for installment Enter your choice: i Down 3000 Prelim 4720 Midtem : 4720 Finals 2360.40

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!