Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Program in C++ Program for everyday life problems, which requires loops using C+

ID: 3698997 • Letter: P

Question

Program in C++

Program for everyday life problems, which requires loops using C++

1. Write a C++ program that displays a student tuition report.

– A loop in the program should ask the user for

• a fictitious student ID number,

• total financial aid received by the student,

• amount paid for tuition,

• amount paid for fees,

• amount paid for books,

• amount paid for housing,

• and amount paid for the meal plan.

– The loop will terminate when 0 is entered for the student ID number.

– After the data for all students is entered and the loop terminates, the program should display

overall totals for all the students for

• financial aid,

• tuition,

• fees,

• books,

• housing,

• meal plan

• and remaining costs

– Program documentation is needed

• The major functionalities, variables, and statements are needed to be described by using

comments.

Explanation / Answer

Below is your code: -

#include <iostream>
using namespace std;


double getValidFinancialAid();
double getValidNumber();
int main()
{
// Declaring variables
const int SENTINEL = 0;
int studId = 0;
double financialAid = 0, totFinbalcuialAid = 0;
double tuitionFee = 0, totTuitionFee = 0;
double fee = 0, totFee = 0;
double booksFee = 0, totBooksFee = 0;
double housingFee = 0, totHousingFee = 0;
double mealsFee = 0, totMealsFee = 0;
double remCost = 0;


// getting the inputs entered by the user
cout << "Enter the Student ID :";
cin >> studId;


if (studId != SENTINEL)
{
// This loop continues to execute until the user enters Zero as Student ID
while (studId != SENTINEL)
{
// Getting the inputs entered by the user
cout << "Enter Total Financial Aid :$";
financialAid = getValidFinancialAid();

// calculating the Total Financial Aid
totFinbalcuialAid += financialAid;

cout << "Enter Amount Paid for Tuition :$";
tuitionFee = getValidNumber();

// calculating the Total Tuition Aid
totTuitionFee += tuitionFee;

cout << "Enter Amount Paid for Fee :$";
fee = getValidNumber();

// calculating the Total Fee
totFee += fee;

cout << "Enter Amount Paid for Books :$";
booksFee = getValidNumber();

// calculating the Total Books fee
totBooksFee += booksFee;

cout << "Enter Amount Paid for Housing :$";
housingFee = getValidNumber();
// calculating the Total Housing fee
totHousingFee += housingFee;

cout << "Enter Amount Paid for Meal Plan :$";
mealsFee = getValidNumber();
// calculating the Total Meals fee
totMealsFee += mealsFee;

// calculating the Total remaining cost
remCost += (financialAid - (tuitionFee + fee + booksFee + housingFee + mealsFee));

cout << " Enter the Student ID :";
cin >> studId;
}

// displaying the output
cout << " Total Financial AID :$" << totFinbalcuialAid << endl;
cout << "Total Tution Fee :$" << totTuitionFee << endl;
cout << "Total Fee :$" << totFee << endl;
cout << "Total Books Fee :$" << totBooksFee << endl;
cout << "Total Housing Fee :$" << totHousingFee << endl;
cout << "Total Meals Fee :$" << totMealsFee << endl;
cout << "Total Remaining Amount :$" << remCost << endl;
}
else
{
cout << ":: No Data ::" << endl;
}

return 0;
}
double getValidNumber()
{
double num;
while (true)
{
cin >> num;
if (num <= 0)
{
cout << "Invalid.Must be Greater than zero." << endl;
cout << "Re-enter:";
continue;
}
else
break;
}
return num;
}

double getValidFinancialAid()
{
double financialAid;
while (true)
{
cin >> financialAid;
if (financialAid < 0)
{
cout << "Invalid.Must be Greater than or equal to zero." << endl;
cout << "Re-enter:";
continue;
}
else
break;
}
return financialAid;
}

Output

Enter the Student ID :121
Enter Total Financial Aid :$1212121
Enter Amount Paid for Tuition :$223332
Enter Amount Paid for Fee :$223232
Enter Amount Paid for Books :$32
Enter Amount Paid for Housing :$3232
Enter Amount Paid for Meal Plan :$232

Enter the Student ID :3223
Enter Total Financial Aid :$3233
Enter Amount Paid for Tuition :$32323
Enter Amount Paid for Fee :$32232
Enter Amount Paid for Books :$322332
Enter Amount Paid for Housing :$332
Enter Amount Paid for Meal Plan :$32322

Enter the Student ID :32232
Enter Total Financial Aid :$323232
Enter Amount Paid for Tuition :$32232
Enter Amount Paid for Fee :$32323
Enter Amount Paid for Books :$32322
Enter Amount Paid for Housing :$3232
Enter Amount Paid for Meal Plan :$32

Enter the Student ID :0


Total Financial AID :$1.53859e+006
Total Tution Fee :$287887
Total Fee :$287787
Total Books Fee :$354686
Total Housing Fee :$6796
Total Meals Fee :$32586
Total Remaining Amount :$568844

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote