Question
How do I add the following functions to my code? int checkCourseNumber ( int crn ); This function returns 0 if the passed crn isnt
How do I add the following functions to my code?
int checkCourseNumber ( int crn ); This function returns 0 if the passed crn isnt from the list of allowable crns. It returns 1 otherwise.
int getCreditHours ( int crn ) This function uses a switch structure and returns the number of credit hours that go with the passed crn. For instance getCreditHours (4599 ) returns 3
void printInvoiceLine ( int crn, int creditHours); This function, when called, prints something like:
4599 3 $360.75
if crn is 4599 and creditHours is 3. This function should be called at most two times because a student takes up to two courses.
void printInvoice ( int id, int crn1, int crn2 ); This function prints the fee invoice. Note that this function may call printInvoiceLine.
Here is my code:
#include
printf("Enter the students Id: \t"); scanf("%d", &studentId);
printf(" Enter how many courses taken(up to 2): \t"); scanf("%d", &numCourses); while(numCourses < 1 || numCourses > 2){ printf(" Invalid number of courses. "); printf("Please re-enter how many courses (up to 2): \t"); scanf("%d", &numCourses);
}
printf(" Enter the 2 course numbers separated by - : (like 2356-8954) \t"); scanf("%d", &courseId[0]); for(i = 1; i < numCourses; i++){ scanf("%c", &hyphen); scanf("%d", &courseId[1]); }
printf(" Thank you! "); printf("PRESS ANY KEY TO CONTINUE... "); getchar(); getchar();
printf(" \t\t\t VALENCE COMMUNITY COLLEGE"); printf(" \t\t\t ORLANDO FL 10101 ");
printf(" \t\t\t Fee Invoice Prepared for Student V%d ", studentId); printf(" \t\t\t 1 Credit Hour = $%.2f ", FEE_PER_CREDIT_HOUR); printf(" \t\t\t %-10s %-12s ","CRN", "CREDIT HOURS"); for(i = 0; i < numCourses; i++){ if(courseId[i] == 4587) creditHours = 4; else if(courseId[i] == 4599 || courseId[i] == 9696) creditHours = 3; else if(courseId[i] == 8997) creditHours = 1; else creditHours = 0; courseFee = creditHours * FEE_PER_CREDIT_HOUR; printf(" \t\t\t %-10d %-18d $ %6.2f ", courseId[i], creditHours, courseFee); total_fees += courseFee;
}
printf(" \t\t\t %-10s %-18s $ %6.2f ", " ", "Health & Id fees", HEALTH_ID_FEES); total_fees += HEALTH_ID_FEES; printf(" \t\t\t ------------------------------ ");
printf(" \t\t\t %-10s %-18s $ %6.2f ", " ", "Total Payments", total_fees);
}
how do I add the functions given and replace lines in my original code?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started