Question

CS 1050 Homework Assignment 2 – SUMMER 2017 DUE Friday, July 7th at 5PM WARNING –...

CS 1050 Homework Assignment 2 – SUMMER 2017

DUE Friday, July 7th at 5PM

WARNING – Technology failing is not an excuse to turn in your assignment late. START EARLY so you will have time to fix problems before the deadline.

Directions: Complete the following homework assignment using the description given in each section.

Purpose:

The Tuition.c program will be used to

Read in the Student ID (an integer value) and use an array search see if the ID is a valid one

Issue appropriate prompts and calculate the tuition for each Student using a SEPARATE FUNCTION for each Student type (1-undergrad, 2-graduate, 3-PhD)

Print out the tuition information in ASCENDING SORTED ORDER by Student.

Submission information:

Submit this assignment by the deadline – NO LATER! If you have problems with this contact Jacob (the TA) or myself. DO NOT WAIT TILL THE LAST DAY TO EMAIL. Do not submit on blackboard or by email!

Description:

student type 1 (UNDERGRADUATE) – an undergraduate student has the following guidelines:
            a) they must sign up for at least 3 hours but no more than 18 hours of classes
            b) their tuition is calculated at $750/hour
            c) they are eligible for scholarships up to 50% of their tuition amount

student type 2 (GRADUATE) – a graduate student has the following guidelines:
            a) they must sign up for at least 3 hours but no more than 9 hours of classes
            b) their tuition is calculated at $1,000/hour
            c) they are eligible for scholarships up to 75% of their tuition

student type 3 (PhD) – a PhD student has the following guidelines:
            a) they must sign up for at least 3 hours but no more than 9 hours of classes
            b) their tuition is calculated at $1,200/hour
            c) they are eligible for up to $10,000 stipend (must be a dollar amount)

In this portion of the assignment you must make use of C's input capabilities. You must prompt the user to enter a Student ID. Valid ID’s and Student type will be stored in your program in a two dimension array and include:

                  int stuInfo [] []={ {394003920, 2},                      double billInfo [][] {   {0.0, 0.0, 0.0},

                                                 {388920394, 3},                                                        {0.0, 0.0, 0.0},

                                                 {499230076, 1},                                                        {0.0, 0.0, 0.0},

                                                 {298760112, 2},                                                        {0.0, 0.0, 0.0},

                                                 {592493811, 3}                                                         {0.0, 0.0, 0.0},

                                                 {355982306, 3} };                                                     {0.0, 0.0, 0.0} };

The array “billInfo[][]” will be initialized with zeros and then will eventually be used to store the tuition information for each Student type. For Student 592493811 it will have the following information:

            billInfo[4][0]=665.00

            billInfo[4][1]=146.30

            billInfo[4][2]=518.70

because Student 592493811 is in row “4” of stuInfo[][] and column “0” is total bill, column “1” is discounts and column “2” is net bill.

checkID() function prototype: int checkID(int idEntered);

This function will received the user entered ID (inputID), will search the global stuInfo [][] array to see if the ID the user entered matches an ID in the array. If it does, then pass the Student’s row back to the calling line of code. If the id entered does NOT match an ID in the array then pass back a -1 to the calling line of code to indicate it was not found and an error should be issued. A simple switch statement will make this work in the main function:

int rowID = checkID (inputID);

switch ( stuInfo[rowID] [1]) ) {

case 1: processUndergrad(rowID);

            break;

case 2: processGraduate(rowID);

            break;

case 3: processPhD(rowID);

            break;

default: processBadID(inputID); //processBadID is an optional function but must print out error message.

}

processUndergrad(), processGraduate(), processPhD()
function prototypes: void process<type>(int rowNumber);

<type> is either Undergrad, Graduate, or PhD. All should have the same parameters and return type.

These functions will receive the ROW for the valid ID entered. It should then prompt the user for the information to calculate that type of Student. For example, if ID 499230076 is entered (type “1” – a undergrad) then processUndergrad() will be invoked and it will prompt the user to enter the Undergrad tuition just like homework 1. If ID 592493811 is entered (type “3” – a PhD student) then processPhD() will be invoked and it will prompt the user to enter the PhD rate and stipend just like homework 1.

processFinalReport() function prototype: void processFinalReport();

This function will be used to produce a report SORTED by the Student ID. If an ID has not been entered DO NOT display the row for it.

Example Output:

$ .a/.out

Enter Student ID: 99939493

ERROR – Invalid Student ID

Enter Student ID: 298760112

Enter credit hours: 11

ERROR – Graduate Students can take no more than 9 hours

Enter credit hours: 9

Enter Scholarship Amount: $ 0.0

Graduate Student 298760112 Tuition is:

Gross        $ 9000.00
Scholarships $    0.00

Tuition Bill $ 9000.00

Enter Student ID: 388920394

Enter credit hours: 3

Enter Stipend Amount: $ 5000

PhD Student 388920394 Tuition is:

Gross        $ 3600.00

Stipend Amt $ 5000.00

Tuition Bill $-1400.00

Enter Student ID: 499230076

Enter credit hours: 17

Enter Scholarship Amount: $ 9000.00

ERROR – Scholarship Amount cannot be larger than 50% of Tuition

Enter Scholarship Amount: $ 3559

Undergraduate Student 499230076 Tuition is:

Gross        $ 12750.00

Scholarships $ 3559.00

Tuition Bill $ 9191.00

Enter Student ID: -1

When the user enters -1, then function processFinalReport() will be invoked to produce the following report:

STUDENT BILLING REPORT (SORTED BY STUDENT ID)

ID                    TYPE              GROSS           DISCOUNTS NET

298760112      4                    1064.50           234.19             830.31

355982306      4                    1482.93           326.24             1156.69

388920394      3                    989.67             217.73             771.94

394003920      2                    2315.96           509.51             1806.45

499230076      1                    3517.00           773.74             2743.26

592493811      3                    665.00             146.30             518.70

                                                ------------         ------------         -----------

                        TOTAL           10035.06         2207.71           7827.35

Make sure you format the input and output exactly as above. Use of “$” signs, etc. should match this exactly.

Files to Submit:

Tuition.c

SUMMARY

Functions required:

checkID()

processUndergrad()

processGraduate()

processPhD()

processFinalReport()

Additional functions are fine but you must define the ones above exactly as shown.

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

SOURCE CODE:

#include <stdio.h>
#include <stdlib.h>
int stuinfo[10][2];
double billinfo[6][3];
int l[10];
int o=0;
int n;
double q=0,w=0,e=0;
int checkID(int identered)
{
int i=0;
for(i=0;i<n;i++)
{
if(identered==stuinfo[i][0]) return i;
}
return -1;
}
void processBadID(int inputID)
{
printf("Your ID:%d did not match any ID in our records.\n",inputID);
}
void processUndergrad(int rowID)
{
int hrs;
double h;
again1:
printf("Enter hours more than 3 but less than 18\n");
scanf("%d",&hrs);
if(hrs<3 || hrs>18)
{
printf("Wrong number of hours. Enter again\n");
goto again1;
}
billinfo[rowID][0]=hrs*750;
again2:
printf("Enter scholarship amount\n");
scanf("%lf",&billinfo[rowID][1]);
h=billinfo[rowID][1]/billinfo[rowID][0];
if(h>=5)
{
printf("Scholarship amount exceeded.Enter again\n");
goto again2;
}
billinfo[rowID][2]=billinfo[rowID][0]-billinfo[rowID][1];
}
void processGraduate(int rowID)
{
int hrs;
double h;
again3:
printf("Enter hours more than 3 but less than 9\n");
scanf("%d",&hrs);
if(hrs<3 || hrs>9)
{
printf("Wrong number of hours. Enter again\n");
goto again3;
}
billinfo[rowID][0]=hrs*1000;
again4:
printf("Enter scholarship amount\n");
scanf("%lf",&billinfo[rowID][1]);
h=billinfo[rowID][1]/billinfo[rowID][0];
if(h>=7.5)
{
printf("Scholarship amount exceeded.Enter again\n");
goto again4;
}
billinfo[rowID][2]=billinfo[rowID][0]-billinfo[rowID][1];
}
void processPhD(int rowID)
{int hrs;
again5:
printf("Enter hours more than 3 but less than 9\n");
scanf("%d",&hrs);
if(hrs<3 || hrs>9)
{
printf("Wrong number of hours. Enter again\n");
goto again5;
}
billinfo[rowID][0]=hrs*1200;
again6:
printf("Enter stipend\n");
scanf("%lf",&billinfo[rowID][1]);

if(billinfo[rowID][1]>10000)
{
printf("Stipend amount exceeded.Enter again\n");
goto again6;
}
billinfo[rowID][2]=billinfo[rowID][0]-billinfo[rowID][1];
}
void swap(int *a, int *b)
{
int temp;
temp = *a;
*a = *b;
*b = temp;


}
void _print(int a)
{
int i=checkID(a);
printf("%d %d %lf %lf %lf\n",stuinfo[i][0],stuinfo[i][1],billinfo[i][0],billinfo[i][1],billinfo[i][2]);
q=q+billinfo[i][0];
w=w+billinfo[i][1];
e=e+billinfo[i][2];
}
void processFinalReport()
{
int i, j;
o=o+1;
for (i = 0 ; i < o;i++)
{
for (j = i ; j < o; j++)
{
if (l[i] > l[j])
swap(&l[i], &l[j]);

}
}

printf("STUDENT BILLING REPORT(SORTED BY ID)\nID\tTYPE\tGROSS\tDISCOUNT\tNET\n");

for(i=1;i<o;i++)
{
_print(l[i]);
}

printf("\t\t-------\t-------\t-------\n\tTOTAL\t%lf\t%lf\t%lf\n",q,w,e);
}
int main()
{
int rowID;
int i=0,j=0,p;
char c='y';
for(i=0;i<6;i++)
{
for(j=0;j<3;j++)
{
billinfo[i][j]=0.0;
}
}
n=0;
while(c=='y')
{
again:
printf("Enter student id\n");
scanf("%d",&stuinfo[n][0]);
if(((stuinfo[n][0]/100000000)<1)||((stuinfo[n][0]/100000000)>9))
{
printf("Invalid ID.Enter again.\n");
goto again;
}
again_:
printf("Enter student type. 1-undergrad, 2-graduate, 3-PhD\n");
scanf("%d",&stuinfo[n][1]);
if(stuinfo[n][1]>3||stuinfo[n][1]<1)
{
printf("Wrong input. Enter again\n");
goto again_;
}
n++;
printf("Do you want to enter more?\n");
fflush(stdin);
scanf("%c",&c);
}
while(1)
{
printf("Enter an ID.-1 to exit\n");
fflush(stdin);
scanf("%d",&p);
if(p==-1)break;
rowID = checkID (p);
switch (stuinfo[rowID][1])
{
case 1: processUndergrad(rowID);
l[o]=p;
o++;
break;
case 2: processGraduate(rowID);
l[o]=p;
o++;
break;
case 3: processPhD(rowID);
l[o]=p;
o++;
break;
default: processBadID(p); //processBadID is an optional function but must print out error message.
}
}
processFinalReport();
return 0;
}

SCREENSHOTS:

Add a comment
Know the answer?
Add Answer to:
CS 1050 Homework Assignment 2 – SUMMER 2017 DUE Friday, July 7th at 5PM WARNING –...
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
  • 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...

  • In C++, write a complete program that receives a series of student records from the keyboard...

    In C++, write a complete program that receives a series of student records from the keyboard and stores them in three parallel arrays named studentID and courseNumber and grade. All arrays are to be 100 elements. The studentID array is to be of type int and the courseNumber and grade arrays are to be of type string. The program should prompt for the number of records to be entered and then receive user input on how many records are to...

  • Assignment 10 Assignments Guidelines This assignment has ONE question. Make sure you answer it an...

    IN Visual Basic please share also Desiger.vb Assignment 10 Assignments Guidelines This assignment has ONE question. Make sure you answer it and include comments. You will lose-10% ofyour grade in this assignment if the comments are missing Bill Calculator You need to design an application that user can enter his/her name, select their level: graduate vs. undergraduate, then they would enter the bill amount. See picture belovw Bill Calculator Please enter your Full name O Graduate Student Undergraduate Student Total...

  • Files given in this assignment (right-click on the file to download) Assignment7.cpp (need to complete) Student.h...

    Files given in this assignment (right-click on the file to download) Assignment7.cpp (need to complete) Student.h (Given. Just use it, don't change it!) Student.cpp (Partially filled, need to complete) 1. Assignment description In this assignment, you will write a simple class roster management system for ASU CSE100. Step #1: First, you will need to finish the design of class Student. See the following UML diagram for Student class, the relevant header file (class declaration) is given to you as Student.h,...

  • CSE/EEE230 Assignment11 Due Date Thursday, April 25th, 5pm Note: the lowest scored assignment wil...

    CSE/EEE230 Assignment11 Due Date Thursday, April 25th, 5pm Note: the lowest scored assignment will be dropped. Important: This is an individual assignment. Please do not collaborate. It must be submitted on-line (Blackboard). No late assignment will be accepted Minimal Submitted Files You are required to turn in the following source file: assignment11.s Objectives: -write assembly language programs to:             -perform arithmetic on floating point numbers             -use syscall operations to display floating point numbers and strings on the console window             -use syscall...

  • C Program Assignment: 2-Add comments to your program to full document it by describing the most...

    C Program Assignment: 2-Add comments to your program to full document it by describing the most important processes. 3-Your variables names should be very friendly. This means that the names should have meaning related to what they are storing. Example: Instead of naming the variable that stores the hours worked for an employee in a variable called ‘x’ you should name it HoursWorked. 5-Submit your .c program (note that I only need your source code and not all files that...

  • write a C++program to analyze a small subset of the data that has been collected. See...

    write a C++program to analyze a small subset of the data that has been collected. See file universities.txt .Use precisely seven parallel arrays: one for name of university, one for state, one for city, one for yearly tuition, one for enrollment, one for average freshman retention, and one for the percent of students who graduate with in six years. Note that the percentage of student accepted is not stored.An output file is opened in main() and remains open until the...

  • Please!!! need help asap!!!! write a C++program to analyze a small subset of the data that...

    Please!!! need help asap!!!! write a C++program to analyze a small subset of the data that has been collected. See file universities.txt .Use precisely seven parallel arrays: one for name of university, one for state, one for city, one for yearly tuition, one for enrollment, one for average freshman retention, and one for the percent of students who graduate with in six years. Note that the percentage of student accepted is not stored.An output file is opened in main() and...

  • C++ Programming

    PROGRAM DESCRIPTIONIn this project, you have to write a C++ program to keep track of grades of students using structures and files.You are provided a data file named student.dat. Open the file to view it. Keep a backup of this file all the time since you will be editing this file in the program and may lose the content.The file has multiple rows—each row represents a student. The data items are in order: last name, first name including any middle...

  • Program 7 Arrays: building and sorting (100 points) Due: Friday, October 30 by 11:59 PM Overview...

    Program 7 Arrays: building and sorting (100 points) Due: Friday, October 30 by 11:59 PM Overview For this assignment, write a program that will calculate the quiz average for a student in the CSCI 240 course. The student's quiz information will be needed for later processing, so it will be stored in an array. For the assignment, declare one array that will hold a maximum of 12 integer elements (ie. the quiz scores). It is recommended that this program be...

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
ADVERTISEMENT