Question

You will modify Project 3 to include a student struct. The struct should include 3 data...

You will modify Project 3 to include a student struct. The struct should include 3 data members a char array (for the name), a char array (for the housing response), and an int (for units). The four functions will all need to be modified to take a pointer to a student struct. Make the necessary modifications to the code in the function body.

You will also provide a menu interface for the user. The menu will initially allow the user to enter a student or quit the application. Once the user has entered a student, the option to print all students should be added to the menu. When the user quits the application, print the student name and amount due for each student entered. Then print the total and average tuition cost for all students entered during that session. If no students were entered, print something stating no students were entered. Allow the user to enter up to 10 students in one session.

Sample Run:

**************************************************
Student Data Entry Application
**************************************************
1: Enter a student
q: Quit the application
>>> 1

Enter student name: Student One
Enter yes if student lives on campus, no otherwise: yes
Enter current unit count: 15

1: Enter a student
2: Print student list
q: Quit the application
>>> 2

Student name: Student One
Housing response: yes
Units Enrolled: 15

1: Enter a student
2: Print student list
q: Quit the application
>>> 1

Enter student name: Student Two
Enter yes if student lives on campus, no otherwise: no
Enter current unit count: 7

1: Enter a student
2: Print student list
q: Quit the application
>>> 1

Enter student name: Student Three Jr.
Enter yes if student lives on campus, no otherwise: yes
Enter current unit count: 11

1: Enter a student
2: Print student list
q: Quit the application
>>> q

Student name: Student One
Amount due: $2470

Student name: Student Two
Amount due: $700

Student name: Student Three Jr.
Amount due: $2100

The total cost is $5270.00.
The average cost for these 3 students is $1756.67.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the code below:::

#include <stdio.h>
#include <stdlib.h>

struct student{
   char name[100];
   char housing[100];
   int count;
};
void printMenu(){
   printf("1: Enter a student\n");
   printf("2: Print student list\n");
   printf("q: Quit the application\n");
}

int main(int argc,char * argv[])
{
   printf("*************************************************\n");
   printf("Student Data Entry Application\n");
   printf("*************************************************\n");
   struct student students[10];
   int index = 0;
   char choice;
   while(1){
       printMenu();
       printf("Enter your choice : ");
       scanf("%c",&choice);
       while(choice=='\n'){
       scanf("%c",&choice);  
       }
       if (choice=='1'){
           printf("Enter student name: ");
           scanf("%s",students[index].name);

           printf("Enter yes if student lives on campus, no otherwise: ");
           scanf("%s",students[index].housing);

           printf("Enter current unit count: ");
           scanf("%d",&students[index].count);

           index++;
           if(index==10){
               break;
           }
       }else if(choice=='2'){
           int i;
           for(i=0;i<index;i++){
               printf("Student Name : %s\n",students[i].name);
               printf("Housing response : %s\n",students[i].housing);
               printf("Units Enrolled : %d\n",students[i].count);
               printf("\n\n");
           }
       }else{
           break;
       }
   }
  
  
   float amountDue = 0;
           float dueAmount;
           int i;
           for(i=0;i<index;i++){
               printf("Student Name : %s\n",students[i].name);
               printf("Amount Due : ");
               scanf("%f",&dueAmount);
               amountDue+=dueAmount;
           }

           printf("The Total cost is : %.3f\n",amountDue);
           printf("The average cost for these %d students is $%.3f.",index,amountDue/index);
       return 0;
  
}

output:

Add a comment
Know the answer?
Add Answer to:
You will modify Project 3 to include a student struct. The struct should include 3 data...
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
  • Assignment Write a menu-driven C++ program to manage a class roster of student names that can...

    Assignment Write a menu-driven C++ program to manage a class roster of student names that can grow and shrink dynamically. It should work something like this (user input highlighted in blue): Array size: 0, capacity: 2 MENU A Add a student D Delete a student L List all students Q Quit ...your choice: a[ENTER] Enter the student name to add: Jonas-Gunnar Iversen[ENTER] Array size: 1, capacity: 2 MENU A Add a student D Delete a student L List all students...

  • Write a menu-driven C++ program to manage a class roster of student names that can grow...

    Write a menu-driven C++ program to manage a class roster of student names that can grow and shrink dynamically. It should work something like this (user input highlighted in blue): Array size: 0, capacity: 2 MENU A Add a student D Delete a student L List all students Q Quit ...your choice: a[ENTER] Enter the student name to add: Jonas-Gunnar Iversen[ENTER] Array size: 1, capacity: 2 MENU A Add a student D Delete a student L List all students Q...

  • I JUST NEED HELP WITH DISPLAY PART! please help! thanks in advance // This function saves...

    I JUST NEED HELP WITH DISPLAY PART! please help! thanks in advance // This function saves the array of structures to file. It is already implemented for you. // You should understand how this code works so that you know how to use it for future assignments. void save(char* fileName) { FILE* file; int i; file = fopen(fileName, "wb"); fwrite(&count, sizeof(count), 1, file); for (i = 0; i < count; i++) { fwrite(list[i].name, sizeof(list[i].name), 1, file); fwrite(list[i].class_standing, sizeof(list[i].class_standing), 1, file);...

  • // READ BEFORE YOU START: // You are given a partially completed program that creates a...

    // READ BEFORE YOU START: // You are given a partially completed program that creates a list of students for a school. // Each student has the corresponding information: name, gender, class, standard, and roll_number. // To begin, you should trace through the given code and understand how it works. // Please read the instructions above each required function and follow the directions carefully. // If you modify any of the given code, the return types, or the parameters, you...

  • // C code // If you modify any of the given code, the return types, or...

    // C code // If you modify any of the given code, the return types, or the parameters, you risk getting compile error. // Yyou are not allowed to modify main (). // You can use string library functions. #include <stdio.h> #include <stdlib.h> #include <string.h> #pragma warning(disable: 4996) // for Visual Studio #define MAX_NAME 30 // global linked list 'list' contains the list of patients struct patientList {    struct patient *patient;    struct patientList *next; } *list = NULL;  ...

  • a. Define the struct node that can store a name and up to 3 phone numbers...

    a. Define the struct node that can store a name and up to 3 phone numbers (use an array for the phone numbers). The node struct will also store the address to the next node. b. Define a class contactList that will define a variable to keep track of the number of contacts in the list, a pointer to the first and last node of the list. c. Add the following methods to the class: i. Add a new contact....

  • Modify the below code to fit the above requirements: struct node { char data; struct node...

    Modify the below code to fit the above requirements: struct node { char data; struct node *next; struct node *previous; } *front, *MyNode, *rear, *MyPointer, *anchor *Valuenode ; typedef struct node node; int Push(char input) { if(IsFull()==1) {   printf("The queue is full. Enter the ‘^’ character to stop.\n"); return -1; } else if (IsFull()==-1) { node *MyNode=(node*)malloc(sizeof(node)); MyNode->data=input; rear->next=MyNode; MyNode->previous=rear; MyPointer=rear=MyNode; return 1; } else { node *MyNode=(node*)malloc(sizeof(node)); node *anchor=(node*)malloc(sizeof(node)); MyNode->data=input; MyPointer=rear=front=MyNode; MyNode->previous=NULL; MyNode->next=NULL; anchor->next=MyNode; return 0; } } char...

  • #include <stdio.h> #include <stdlib.h> #include <string.h> struct game_piece { ...

    #include <stdio.h> #include <stdlib.h> #include <string.h> struct game_piece { }; struct game_board { }; void game_piece_init_default(struct game_piece* piece) { } void game_piece_init(struct game_piece* piece, char* new_label) { } char* game_piece_get_label(struct game_piece* piece) { return ""; } char* game_piece_to_string(struct game_piece* piece) { return ""; } void game_board_init(struct game_board* game_board, int rows, int cols) { } int game_board_is_space_valid(struct game_board* game_board, int row, int col) { return 0; } int game_board_add_piece(struct game_board* game_board, struct game_piece* piece, int row, int col) { return 0;...

  • In C++ Write a menu driven C++ program to read a file containing information for a list of Students, process the data, t...

    In C++ Write a menu driven C++ program to read a file containing information for a list of Students, process the data, then present a menu to the user, and at the end print a final report shown below. You may(should) use the structures you developed for the previous assignment to make it easier to complete this assignment, but it is not required. Required Menu Operations are: Read Students’ data from a file to update the list (refer to sample...

  • This program will store a roster of most popular videos with kittens. The roster can include...

    This program will store a roster of most popular videos with kittens. The roster can include at most 10 kittens.You will implement structures to handle kitten information. You will also use functions to manipulate the structure. (1) Create a structure kitten. The structure should contain the following attributes: name; string color; string score; integer Important! The name of the structure and each of its field must match exactly for the program to work and be graded correctly. (2) Create a...

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