The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
I have attached a text file where I am trying to complete the project below. Can someone tell me what is wrong with the last of my code.Â
Â
Â
In this project you will create a program that will calculate a student’s tuition for a given semester. Since you will be dealing with money you will need to use a double datatype when creating your variables that hold the number of credit hours and the tuition cost. The program will prompt the user for the number of classes you are registering for this semester. It should then prompt you to enter in the number of credit hours for each of those classes. Here are some of the main variables you will need to create for the program:
Â
Once you have gotten the number of courses and prompted the user for the number of credit hours for each class then you need to call a function and pass it the following items. This function will calculate and return your total tuition cost.
The formula for calculating the tuition is:
if sumCreditHoursTaken is less than or equal to maxHoursFullTuition then the tuition is
                       sumCreditHoursTaken * costCreditHour
Otherwise if the sumCreditHoursTaken is greater than PmaxHoursFullTuition then the tuition is
(maxHoursFullTuition * costCreditHour) + ((sumCreditHoursTaken - maxHoursFullTuition) * maintFeeAddOn)
You should output the total number of hours the student is taking and the total tuition cost.
Formatting the output: You will need to format the final tuition with a $ and 2 decimal points precision.
This project covers methods you have learned in chapters 2 through 6.
Â
Program Output:
Â
              This program calculate a student’s total number of
              credit hours and tuition for a given semester.
Â
Please enter the number of courses you will be taking this semester: 5
Please enter the number of credit hours for course 1: 3
Please enter the number of credit hours for course 2: 3
Please enter the number of credit hours for course 3: 3.5
Please enter the number of credit hours for course 4: 4
Please enter the number of credit hours for course 5: 2.5
Â
Your total number of credit hours is: 16.00
Your total tuition will be $1881.32
Â
Press any key to continue . . .
Â
#include "stdafx.h"#include <iostream>#include <iomanip>using namespace std;int main(){int numCourses,// Number of CoursessumCreditHoursTaken;// Hold the total number of credit hoursthe student is takingdouble total = 0,//Accumulator for total Credit hourcostCreditHour//Default $147.00 this is the cost ofhours 1 through 12maxHoursFullTuition//Default 12, indicates hours 1through 12 are at full tuitionmaintFeeAddOn//Default $29.33 indicates the cost ofhours 13 and abovetuitionCost//Regular costpremiumTuitionCost//Premium Cost//Functiondouble gettuitionCost (double);double getpremiumTuitionCost (double);// Get the number of courses taken.cout << "This program calculates the cost of tuition.\n";cout << "How many courses are you taking? ";cin >> numCourses;// Determine the total credit hours and accumulate a totalfor (int CreditHoursTaken = 1; CreditHoursTaken <= numCourses;CreditHoursTaken++){int sumCreditHoursTaken;cout << "Enter credit hours for course " << CreditHoursTaken << ":";cin >> sumCreditHoursTaken;total += sumCreditHoursTaken;}// Display the total Credit Hours Takencout << "The total credit hours taken are" << total << endl;return 0;costCreditHour = 147.00maxHoursFullTuition = 12maintFeeAddOn = 29.33}if (sumCreditHoursTaken <= maxHoursFullTuition)gettuitionCost = sumCreditHoursTaken * costCreditHour;else (sumCreditHoursTaken > maxHoursFullTuition)getpremiumTuitionCost = (maxHoursFullTuition * costCreditHour) +((sumCreditHoursTaken - maxHoursFullTuition) * maintFeeAddOn);// Display the Cost.cout << "Your total tuition will be $" << endl;return 0;}
Attachments: