Question

In: Computer Science

The Community College of Denver is proposing a new cost structure for its courses. The plan...

The Community College of Denver is proposing a new cost structure for its courses. The plan is to charge a higher cost for higher level courses in order to hiring highly skilled instructors for those courses. The course levels are as follows:

  • 000 Level Courses - $178.25 / hour
  • 100 Level Courses - $232.42 / hour
  • 200 Level Courses - $274.41 / hour

This new plan also includes a 2 percent per year cost increase for each level over the course of the next five years to bring the college closer to the national average.

Instructions

Design a program that first displays a menu then asks the user the number of credit hours they plan to take in one semester. Use this number to calculate the present semester tuition. The program should then display a menu that asks the user which course level to display in the report. (Note that only one course level can be displayed at a time!). Once the course level is selected, the program MUST use the per credit hour cost listed in the attached text file called tuitionAmounts.txt. Therefore, the initial tuition amounts must be read into the program from the text file and not hard-coded with the program. This allows the initial amounts to be changed in the text file an not in the code.

After the tuition amounts are read, then display the tuition for the level selected for the year by multiplying the semester tuition by 2. Next, create a loop that displays the projected yearly tuition amounts for the next five years. Therefore, the program should display 6 years of tuition with the first year representing the present tuition costs and the subsequent years representing a 2 percent increase each year.

Below is a representation of a sample run of your application. Your output results should be in table format and should resemble the following if the user selected 000 Level Courses:

CCA Tuition Program
-------------------------

1. 000 Level Courses
2. 100 Level Courses
3. 200 Level Courses
4. Exit Program
Select the course level or Exit: 1

Enter the number of credit hours for this semester: 12

Community College of Aurora Tuition Report
                        Level 000
---------------------------------------------
Year
-----
Tuition
-------
Year 1 $4278.00
Year 2 $4363.56
Year 3 $4450.83
Year 4 $4539.85
Year 5 $4630.64
Year 6 $4723.26

Additional Requirements

  • You MUST use a loop to display years 2 through 6, which have the percent increase.
  • You MUST use a switch statement to evaluate the level chosen
  • The program must loop and can only be exited by making a selection in the menu
  • The output results must be written to a new text file called TuitionReportResults.txt.

C++

Solutions

Expert Solution

CODE -

#include<fstream>

#include<iostream>

#include<iomanip>

using namespace std;

int main()

{

    ifstream infile;

    int choice, num_hrs;

    float cost_000, cost_100, cost_200;

    string level;

    float tution_cost;

    // Opening file for reading

    infile.open("tuitionAmounts.txt");

    // Reading the per credit hour cost for different levels from the file.

    infile >> cost_000;

    infile >> cost_100;

    infile >> cost_200;

    // Closing the file

    infile.close();

    ofstream outfile;

    // Opening the file for writing

    outfile.open("TuitionReportResults.txt");

    // Loop to run until user chooses to exit the program

    while(true)

    {

        // Displaying the header and the menu

        cout << "\nCCA Tuition Program" << endl;

        cout << "-------------------------" << endl;

        cout << "1. 000 Level Courses" << endl;

        cout << "2. 100 Level Courses" << endl;

        cout << "3. 200 Level Courses" << endl;

        cout << "4. Exit Program" << endl;

        // Taking choice as input from user

        cout << "Select the course level or Exit: ";

        cin >> choice;

        // Loop to make sure user enters a valid choice.

        while(choice>4 || choice<1)

        {

            cout << "Invalid Choice! Try again!" << endl;

            cout << "Select the course level or Exit: ";

            cin >> choice;

        }

        // Exiting the loop if user chooses 4

        if (choice == 4)

            break;

        // Taking the no. of credit hours as input from user

        cout << "Enter the number of credit hours for this semester: ";

        cin >> num_hrs;

        // Switch case to evaluate tution cost based on user's choice of level

        switch(choice)

        {

            case 1:

                tution_cost = cost_000 * 2 * num_hrs;

                level = "000";

                break;

            case 2:

                tution_cost = cost_100 * 2 * num_hrs;

                cout << cost_100 << endl;

                level = "100";

                break;

            case 3:

                tution_cost = cost_200 * 2 * num_hrs;

                level = "200";

                break;

        }

        // Displaying and writing to file the header and the tuition costs for different years

        cout << "\nCommunity College of Aurora Tuition Report" << endl;

        outfile << "\nCommunity College of Aurora Tuition Report" << endl;

        cout << setw(24) << "Level " << level << endl;

        outfile << setw(24) << "Level " << level << endl;

        cout << "---------------------------------------------" << endl;

        outfile << "---------------------------------------------" << endl;

        cout << std::left << setw(22) << "Year" << std::right << setw(23) << "Tuition" << endl;

        outfile << std::left << setw(22) << "Year" << std::right << setw(23) << "Tuition" << endl;

        cout << std::left << setw(22) << "-----" << std::right << setw(23) << "-------" << endl;

        outfile << std::left << setw(22) << "-----" << std::right << setw(23) << "-------" << endl;

        cout << fixed << setprecision(2);

        outfile << fixed << setprecision(2);

        cout << std::left << setw(20) << "Year 1" << std::right << setw(18) << "$" << tution_cost << endl;

        outfile << std::left << setw(20) << "Year 1" << std::right << setw(18) << "$" << tution_cost << endl;

        // Loop to display and write to file years 2 through 6

        for (int i=2; i<=6; i++)

        {

            // Increasing the cost every year by 2%

            tution_cost += 0.02 * tution_cost;

            cout << "Year " << std::left << setw(15) << i << std::right << setw(18) << "$" << tution_cost << endl;

            outfile << "Year " << std::left << setw(15) << i << std::right << setw(18) << "$" << tution_cost << endl;

        }

    }

    // Closing the file.

    outfile.close();

    return 0;

}

SCREENSHOTS -

CODE -

INPUT TEXT FILE -

OUTPUT -

OUTPUT TEXT FILE -

If you have any doubt regarding the solution, then do comment.
Do upvote.


Related Solutions

1. In Spring 2019, a local community college decided to switch textbooks for their calculus courses....
1. In Spring 2019, a local community college decided to switch textbooks for their calculus courses. In order to compare how students fared with the new book compared to the old book, a professor recorded the average grades that the students received on their exams. The average exam scores of 17 randomly selected students are shown below. State the 5-number summary by clearly labeling each value and create a boxplot for this data. 62.9 73.80 98.5 76.2 81.5 67.8 72.2...
Urban Community College is planning to offer courses in Finite Math, Applied Calculus, and Computer Methods....
Urban Community College is planning to offer courses in Finite Math, Applied Calculus, and Computer Methods. Each section of Finite Math has 40 students and earns the college $40,000 in revenue. Each section of Applied Calculus has 40 students and earns the college $60,000, while each section of Computer Methods has 10 students and earns the college $23,000. Assuming the college wishes to offer a total of seven sections, accommodate 220 students, and bring in $286,000 in revenues, how many...
Your manager is proposing a new investment. If the company pursues the investment, it will cost...
Your manager is proposing a new investment. If the company pursues the investment, it will cost $300,000 today. It has an expected life of 10 years and no salvage value. Annual expenses are estimated to be $30,000 per year. Annual revenue increases are estimated to be $70,000 per year. Your company must borrow 1/3 of the investment cost. The bank has agreed to six equal annual payments, with the first payment due at the end of year 1. The company's...
A community college claims that the standard deviation in the cost of TI calculators is at...
A community college claims that the standard deviation in the cost of TI calculators is at least $15. A simple random sample of 43 stores that sell TI calculators yielded a sample mean of $84 and a sample standard deviation of $12 for the cost of TI calculators. Does this data refute the claim made by the community college? Perform a statistical test at the 5% significance level. You may assume that the cost of TI calculators is normally distributed....
The mayor of a town has proposed a plan for the annexation of a new community....
The mayor of a town has proposed a plan for the annexation of a new community. A political study took a sample of 800 voters in the town and found that 60% of the residents favored annexation. Using the data, a political strategist wants to test the claim that the percentage of residents who favor annexation is more than 55%. Determine the P-value of the test statistic. Round your answer to four decimal places.
The mayor of a town has proposed a plan for the annexation of a new community....
The mayor of a town has proposed a plan for the annexation of a new community. A political study took a sample of 1600 voters in the town and found that 50% of the residents favored annexation. Using the data, a political strategist wants to test the claim that the percentage of residents who favor annexation is less than 53%. Testing at the 0.02 level, is there enough evidence to support the strategist's claim? Step 4 of 7 :   Determine...
The mayor of a town has proposed a plan for the annexation of a new community....
The mayor of a town has proposed a plan for the annexation of a new community. A political study took a sample of 900 voters in the town and found that 40% of the residents favored annexation. Using the data, a political strategist wants to test the claim that the percentage of residents who favor annexation is more than 36%. Testing at the 0.05 level, is there enough evidence to support the strategist's claim? Step 1 of 6 : State...
The mayor of a town has proposed a plan for the construction of a new community....
The mayor of a town has proposed a plan for the construction of a new community. A political study took a sample of 1000 voters in the town and found that 69% of the residents favored construction. Using the data, a political strategist wants to test the claim that the percentage of residents who favor construction is more than 65%. Testing at the 0.02 level, is there enough evidence to support the strategist's claim? Step 1 of 6: State the...
The mayor of a town has proposed a plan for the construction of a new community....
The mayor of a town has proposed a plan for the construction of a new community. A political study took a sample of 900 voters in the town and found that 75% of the residents favored construction. Using the data, a political strategist wants to test the claim that the percentage of residents who favor construction is more than 72%. Testing at the 0.05 level, is there enough evidence to support the strategist's claim?
The mayor of a town has proposed a plan for the construction of a new community....
The mayor of a town has proposed a plan for the construction of a new community. A political study took a sample of 1700 voters in the town and found that 73% of the residents favored construction. Using the data, a political strategist wants to test the claim that the percentage of residents who favor construction is more than 70%. Testing at the 0.05 level, is there enough evidence to support the strategist's claim? Step 1 of 7: State the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT