Ok, I'm not really following...
In lines 1 and 2, is that a revision of the original function (getHowManyClasses)? and if so, why do I rename my declared int's different from the original prototype? Why would I be calling 'courses' instead of 'start' in the int main() ?
Sorry, this is my first programming class and I'm struggling,
I've attached the project and code so far so you've got the whole picture.
Valencia Community College
C++ Programming
Learning Outcomes:
1) Selection statements
2) repetition statements
3) Functions
At Valence community college, a student can’t take more than 3 courses under the constraint of having no more than 7 credit hours. The purpose of this assignment is to construct a fee invoice for a student. This requires the input of Student’s id as integer and the course numbers.
It costs 120.25 dollars per credit hour in addition to $35.00 charged for health and id services.
Here is the list of all courses Valence Community College offers:
CRN Course Prefix Credit Hours
4587 MAT 236 4
4599 COP 220 3
8997 GOL 124 1
9696 COP 100 3
After inputting all the necessary data (see sample run), a fee invoice as shown below should be printed to the screen.
VALENCE COMMUNITY COLLEGE
ORLANDO FL 10101
---------------------
Fee Invoice Prepared for Student V5656
1 Credit Hour = $120.25
CRN CR_PREFIX CR_HOURS
4587 MAT 236 4 $ 481.00
4599 COP 220 3 $ 360.75
Health & id fees $ 35.00
--------------------------------------
Total Payments $ 876.75
Use the following function declarations:
void getId ( int & id);
This function asks for id.
int getHowManyCourses ( int & ndrCourses);
This function asks for number of courses. The number of courses has to be less or equal to 3, otherwise, the user is asked to enter it again.
int getHours ( int crn );
This function returns how many credit hours that go with crn
double getTuitionCost ( int crn);
This function returns how much it cost for crn.
void printInvoice ( int crn1, int crn2, int crn3);
Prints the fee invoice.
Add more functions if you want to!
_______________________________________________________
Sample Run (The user’s entry is in bold)
Enter the Students Id
5656
Enter how many courses-up to 3
6
Invalid number! Try again
Enter how many courses-up to 3
3
Enter the 3 course number(s)
4587 4599 9696
Sorry, you can’t cumulate more than 7 credit hours
Do you want to try again (Y/N)
y
Enter how many courses-up to 3
2
Enter the 2 course number(s)
4587 4599
Thank you!
Press Any Key to Continue
VALENCE COMMUNITY COLLEGE
ORLANDO FL 10101
---------------------
Fee Invoice Prepared for Student V5656
1 Credit Hour = $120.25
CRN CR_PREFIX CR_HOURS
4588 MAT 236 4 $ 481.00
4599 COP 220 3 $ 360.75
Health & id fees $ 35.00
--------------------------------------
Total Payments $ 876.75
Would you like to process another student? (Yes/No): No
Goodbye!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
#include <iostream>
using namespace std;
int getHours ( int crn );
void getPrefix ( string & prefix );
int getHowManyCourses ( int & start );
int getId ();
void printInvoice ( int crn1, int crn2, int crn3 );
//----------------------------
void printInvoice ( int crn1, int crn2, int crn3 )
{
cout <<"\n\nThank you!\n";
cout <<"HERE IS THE FEE INVOICE...\n\n";
cout <<"\n\n";
cout <<"\t\t\tVALENCE COMMUNITY COLLEGE\n";
cout <<"\t\t\tORLANDO FL 10101\n";
cout <<"\t\t\t*************************\n\n";
cout <<"\t\t\tFee Invoice Prepared for Student V5656\n\n";
cout <<"\t\t\t1 Credit Hour = $120.25\n\n";
cout <<"\t\t\tCRN\tCredit Hours\n";
}
//----------------------------
int getId ()
{
int i;
cout << "Enter the Students id : \n\t";
cin >> i;
return i;
}
//----------------------------
int getHowManyCourses ( int start )
{
cout <<"Enter how many courses - up to three(3) : \n\t";
cin >> start;
if ( start <= 3 )
{
cin >> start;
}
else
{
cout << "Invalid number! Try Again!\n\n";
}
return (start+1);
}
//----------------------------
void getPrefix ( int crn , string &prefix )
{
switch ( crn )
{
case 9696 : prefix = "COP 100"; break;
case 4599 : prefix = "COP 220"; break;
case 4587 : prefix = "MAT 236"; break;
case 8997 : prefix = "GOL 124"; break;
}//end of switch
}
//-----------------------------
int getHours ( int crn )
{
switch ( crn )
{
case 9696 :
case 4599 : return 3;
case 4587 : return 4;
case 8997 : return 1;
}//end of switch
}
//------------------------------
int main ()
{
int id;
id = getId ();
int courses = 2;
int answers = getHowManyCourses (courses);
return 0;
int crn , hours;
string prefix = "UNKNOWN";
cout <<"Enter a course number : \n\t";
cin >> crn;
hours = getHours ( crn );
getPrefix ( crn , prefix );
cout << prefix <<" has :"<< hours <<" Credit Hours!\n\n";
system ("pause");
}
|