Question: Help C programming!! You are the head programmer at Cool School University. You are tasked with writing a program to take input for a student

Help C programming!!

You are the head programmer at Cool School University. You are tasked with writing a program to take input for a student and print the cost of attending classes this semester. The unit cost is $100 (use a preprocessor directive to define this as a constant value). Furthermore, if a student is enrolled in more than 12 units, they receive a $10 discount for every unit they take over 12. Students that live on campus are charged an extra $1000 for housing costs. Your tasks are to get a student name with spaces (char array), y or n (char) for living on campus, and number of units enrolled (int) from the console. Calculate the amount due using the criterion above and print the output to the console window. Use the same data types listed above.

Store the student names in a multidimensional array and amounts due in a single dimension array. This will allow you to get input for all 5 students without printing. Then once all 5 students have been entered, print their names and amounts due as shown below.

Write a function called getInput that returns void and takes char* (for name), int (for name length may be optional for some), char* (for y or n response), and int* (for units). In the body of the function prompt the user and store input for a student name, char (y or n) depending on if they live on campus, and int for number of units. Remember when using scanf with pointers no ampersand is needed. fgets/gets stays the same (no ampersand).

e.g. getInput(names[i], nameLen, &onCampus, &units);

You can break this into smaller functions like getName, getHousing, and getUnits but they must be pass by reference.

Write a function called printOutput that returns void and takes a const char* (for name) and const int (for tuition cost). In the body of the function print a label, student name and new line followed by a label and the amount due.

e.g. printOutput(names[i], tuitionCost[i]);

Do NOT use global variables. The global constants defined in previous programs are OK.

Challenge Exercise 1 Allow the user to stop entering data early if -1 is entered as input. The program should print all information currently stored. Calculations must be correct.

Challenge Exercise 2 Make a menu and allow the user to add or print students (up to 5) based on a menu selection.

Sample Run

Enter student name: Tim Berners-Lee

Enter y if student lives on campus, n otherwise: y

Enter current unit count: 15

Enter student name: Edsger W. Dijkstra

Enter y if student lives on campus, n otherwise: n

Enter current unit count: 7

Enter student name: Dennis Ritchie

Enter y if student lives on campus, n otherwise: y

Enter current unit count: 11

Enter student name: Ken Thompson

Enter y if student lives on campus, n otherwise: n

Enter current unit count: 13

Enter student name: Brian Kernighan

Enter y if student lives on campus, n otherwise: y

Enter current unit count: 12

Student name: Tim Berners-Lee

Amount due: $2470

Student name: Edsger W. Dijkstra

Amount due: $700

Student name: Dennis Ritchie

Amount due: $2100

Student name: Ken Thompson

Amount due: $1290

Student name: Brian Kernighan

Amount due: $2200

The average tuition cost for these 5 students is $1752.00.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!