Question

c++ Write a program that computes and displays the tuition for courses offered at the University....

c++

Write a program that computes and displays the tuition for courses offered at the University. First, the program should ask if the student has registered for a regular course or a course with a lab component. The user can enter the letter 'C' or 'c' for lecture course only, or the letter 'L' or 'l' for a laboratory course . Write a function called Menu, which takes no input parameters and returns a char value. Your main program will call this Menu function, which will prompt the user to enter the category ('c'or 'C' for lecture course only or 'l'or 'L' for lecture + lab course) and return the char entered by the user to your main program. For the lab course option, the total of lecture hours and lab hours is limited to 4.

Next in the main program, use the switch statement to get additional information from the user and compute the tuition.

For the course only option, ask the user to enter the following information:

  • The name of course.

  • The number of course lecture credit hours. Has to be in the range of 1-3 (i.e. 1 ≤ credit hours ≤ 3). For the lab course option, ask the user to enter the following information:

  • The name of course.

  • The number of course lecture credit hours. Has to be in the range of 1-3 (i.e. 1 ≤ credit hours ≤ 3).

  • The number of lab credit hours. As defined above since the number of course lecture hours have to be in the

    range of 1-3 (i.e. 1 ≤ lecture credit hours ≤ 3), the lab hours entered can also only be in the range of 1-3 (i.e. 1 ≤ lab hours ≤ 3) to satisfy the condition of total hours of 4. That is the total of the course lecture hours plus the lab hours has to be in the range of 2-4 (i.e. 2 ≤ total (lab + lecture credit hours) ≤ 4). For example, if the lecture credit hours entered is 3, lab hours can only be 1. If course lecture credit hours is 2, lab hours can be 1 or 2. If course lecture credit hours is 1, lab hours can be 1 or 2 or 3.

    OPTIONAL (5 POINTS): You will get bonus points if you write a function/s to read the information above (i.e. name of course, lecture credit hours, lab credit hours) entered by the user.

    Write a pair of overloaded functions called compute_tuition.

  1. The first overloaded function should compute tuition for the course only option as follows,Tuition = lecture credit hours*rate.
    The function should return the tuition amount.

  2. The second overloaded function should compute tuition for the lab course option as follows,

    Tuition = lecture credit hours *RATE + lab credit hours *FEE.

    The function should return the tuition amount.

Use global named constants for the rate per credit hour (RATE = 364.0) and lab fee per credit hour (FEE = 50.0)

Required Items:

  1. Menufunction

  2. Global named constants for RATE and FEE

  3. Switch statement with case labels for course only and course with lab option

  4. Range check on the credit hours entered

  5. Two overloaded functions to compute_tuition

  6. main()totestthefunctionsasshowninthesampleruns

See next page for Sample Runs

ELET 2300, Spring 19, Final Part 2, Total: 50 + 5 (bonus)

Submit your source.cpp file by 1:45 pm

Sample Run 1 (user entered text is in blue)

Program to Compute Course Tuition
For Course Lecture only option, enter C/c For Course with Lab, enter L/l
c
Enter course name:
Intro to C++
Enter lecture credit hrs (range 1-3): 3

Course Name: Intro to C++ Tuition: $1092.00

Sample Run 2 (user entered text is in blue)

Program to Compute Course Tuition
For Course Lecture only option, enter C/c For Course with Lab, enter L/l
l
Enter course name:
Intro to C++ with Lab
Enter lecture credit hrs (range 1-3): 2Enter lab credit hrs (range 1-2): 2

Course Name: Intro to C++ with Lab Tuition: $828.00

Sample Run 3 (user entered text is in blue)

Program to Compute Course Tuition
For Course Lecture only option, enter C/c For Course with Lab, enter L/l
c
Enter course name:
Intro to C++
Enter lecture credit hrs (range 1-3): 0Lecture Credit hrs out of range!
Enter lecture credit hrs (range 1-3): 4Lecture Credit hrs out of range!
Enter lecture credit hrs (range 1-3): 2

Course Name: Intro to C++ Tuition: $728.00

Sample Run 4 (user entered text is in blue)

Program to Compute Course Tuition
For Course Lecture only option, enter C/c For Course with Lab, enter L/l
l
Enter course name:
Intro to C++ with Lab
Enter lecture credit hrs (range 1-3): 0Lecture Credit hrs out of range!
Enter lecture credit hrs (range 1-3): 3Enter lab credit hrs (range 1-1): 0
Lab Credit hrs out of range!
Enter lab credit hrs (range 1-1): 2
Lab Credit hrs out of range!
Enter lab credit hrs (range 1-1): 1

Course Name: Intro to C++ with Lab Tuition: $1142.00

Sample Run 5 (user entered text is in blue)

Program to Compute Course Tuition
For Course Lecture only option, enter C/c For Course with Lab, enter L/l
l
Enter course name:
Intro to C++ with Lab
Enter lecture credit hrs (range 1-3): 1Enter lab credit hrs (range 1-3): 0
Lab Credit hrs out of range!
Enter lab credit hrs (range 1-3): 4
Lab Credit hrs out of range!
Enter lab credit hrs (range 1-3): 2

Course Name: Intro to C++ with Lab

Tuition: $464.00

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>
#include<stdio.h>
using namespace std;
const double RATE = 364.00,FEE=50.00;
//menu()
char menu()
{
   char ch;
   cout<<endl<<" Program to Compute Course Tution";
   cout<<endl<<" For Course Lecture only optin, enter C/c";
   cout<<endl<<" For Course with Lab , enter L/l";;
   cin>>ch;
   return ch;
}
//overloaded method for course
void compute_tution(char s[30], int nc)
{
   cout<<endl<<" Course Name : "<<s;
   cout<<endl<<" Tution : $"<<nc*RATE;
}
//overloaded method for course and lab
void compute_tution(char s[30], int nc,int lc)
{
   cout<<endl<<" Course Name : "<<s;
   cout<<endl<<" Tution : $"<<(nc*RATE)+(lc*FEE);
}


int main()
{
   char opt;
   char cname[30];
   int ch,lh;
       //call to menu()
   opt=menu();
   switch(opt)
   { //case block for course
       case 'c':
       case 'C': //input the name of course
           cout<<endl<<"Enter the name of Course";
           gets(cname);
           top:
           //credit hours for course
           cout<<endl<<"Enter the number of course lecture credit hours(range 1 -3)";
           cin>>ch;
           //validate the course hour
           if(ch<=0 || ch>3)
           {
           cout<<endl<<" Lecture Credit hours out of range!";
           goto top;
           }
           //call to compute_tution() for display the details
           compute_tution(cname,ch);
           break;
       case 'l':
       case 'L': //input the name of course
           cout<<endl<<"Enter the name of Course";
           gets(cname);
           top1:
           //inout the course hours
           cout<<endl<<"Enter the number of course lecture credit hours(range 1 -3)";
           cin>>ch;
           //validate the course hours
           if(ch<=0 || ch>3)
           {
           cout<<endl<<" Lecture Credit hours out of range!";
           goto top1;
           }
           top2:
           //input the lab credits
           cout<<endl<<"Enter the number of Lab credit hours(range 1 -"<<4-ch<<")";
           cin>>lh;
           //validate the lab credits
           if(lh<=0 || lh>(4-ch))
           {
           cout<<endl<<" Lab Credit hours out of range!";
           goto top2;
           }
           //call to compute_tution() to display the details
           compute_tution(cname,ch,lh);
           break;
       default:
       cout<<endl<<"Invalid choice, Try again!"   ;

   }
}

output

Add a comment
Know the answer?
Add Answer to:
c++ Write a program that computes and displays the tuition for courses offered at the University....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Tuition Payment In C++, Write a program that will calculate the total college costs for a...

    Tuition Payment In C++, Write a program that will calculate the total college costs for a student. The program will ask the user for the number of credit hours that the student is taking, the number of lab courses that the student is taking, and whether the student is "in district". The tuition is calculated by multiplying the number of credit hours times the cost per credit plus lab fees. For "in district" students the cost is $70.00 per credit...

  • C++ Write a program that computes and displays the charges for a patient's hospital stay_First, the...

    C++ Write a program that computes and displays the charges for a patient's hospital stay_First, the program should ask if the patient was admitted as an inpatient or an outpatient. If the patient was an inpatient, the following data should be entered: The number of days spent in the hospital The daily rate Charges for hospital services (lab tests, etc.) Hospital medication charges If the patient was an outpatient, the following data should be entered: Charges for hospital services (lab...

  • this program is in C. Write a program that computes the number of elements in an...

    this program is in C. Write a program that computes the number of elements in an array divisible by a user specified number. Declare an integer array of size 7 and read the array elements from the user. Then, read a number k from the user and compute the number of elements in the array divisible by k. Consider the following example. 3 elements in this array are divisible by 2 ({2,2,4}). Sample execution of the program for this array...

  • Description. A university calculates tuition based on student classifications. Resident undergraduate students (living in state) pay...

    Description. A university calculates tuition based on student classifications. Resident undergraduate students (living in state) pay a set amount per credit for 12 or fewer credits and pay 75% of set amount per credit for all additional credits. Non-resident undergraduate students (living out of state) pay $5,000 plus 80% of the set amount for all credits taken. Graduate students pay $9,500 per semester regardless of the number of credits taken. Alumni returning to the university are allowed to audit a...

  • Write a working C program that will do the following: 1. Include your name, Lab Test...

    Write a working C program that will do the following: 1. Include your name, Lab Test number, and student id as comments in the first lines of the program 2. User is first prompted to enter an integer number between 1 and 20, to be stored as variable named number. If the number is outside the range 1-20, the program will end. 3. If the number is within the allowed range, variable number is passed to function multF(). The multF()...

  • Write a working C program that will do the following: 1. Include your name, Lab Test...

    Write a working C program that will do the following: 1. Include your name, Lab Test number, and studentId as comments in the first lines of the program 2. User is first prompted to enter an integer number between 1 and 20, to be stored as variable named number. If the number is outside the range 1-20, the program will end. 3. If the number is within the allowed range, variable number is passed to function multF(). The multF() function...

  • Write a working C program that will do the following: 1.Include your name, Lab Test number,...

    Write a working C program that will do the following: 1.Include your name, Lab Test number, and studentId as comments in the first lines of theprogram 2.User is first prompted to enter an integer number between 1 and 20, to be stored asvariable named number. If the number is outside the range 1-20, the program will end. 3.If the number is within the allowed range, variable number is passed to function multF().The multF() function computes and returns the result of:...

  • (For Python program)   Write a program that fulfills the functionalities of a mathematical quiz with the...

    (For Python program)   Write a program that fulfills the functionalities of a mathematical quiz with the four basic arithmetic operations, i.e., addition, subtraction, multiplication and integer division. A sample partial output of the math quiz program is shown below. The user can select the type of math operations that he/she would like to proceed with. Once a choice (i.e., menu option index) is entered, the program generates a question and asks the user for an answer. A sample partial output...

  • C++ program Write a C++ program to manage a hospital system, the system mainly uses file...

    C++ program Write a C++ program to manage a hospital system, the system mainly uses file handling to perform basic operations like how to add, edit, search, and delete record. Write the following functions: 1. hospital_menu: This function will display the following menu and prompt the user to enter her/his option. The system will keep showing the menu repeatedly until the user selects option 'e' from the menu. Arkansas Children Hospital a. Add new patient record b. Search record c....

  • Write a C program Design a program that uses an array to store 10 randomly generated...

    Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT