Question

I JUST NEED HELP WITH DISPLAY PART!

please help!

thanks in advance

#include #include #include #include <stdio.h> <stdlib.h> <string.h> <ctype.h> #pragma warning(disable: 4996) // for Visual Studio Only typedef enum male , female gender /I enumeration type gender struct student f char name [30]; gender genderValue; char class_standing[10]; int roll number; float tuition_fee; 3: int count = 0; // the number of students currently stored in the list (initialized at 0) struct student list[30]; // initialize list of students // forward declaration of functions void flush); void branching(char); void registration(char); int add(char*, char*, char, int, float, struct student*); // 20 points char search (char*, int, struct student*) // 10 points void display;// 10 points void save (char fileName); void load (char* fileName); 1/ 10 points int main() load( Sudent_List.txt); // load 1ist of students from file (if it exists) char ch i ; printf(Please enter your selection: In); printf(ta: add a new student to the listln); printf(ts:search for a student on the listln) printf(td: display list of students\n) printf(tq: quit\n); ch = tolower(getchar()); flush) branching(ch); (ch } while != q); save( Student List.txt); // save list of students to file (overwrite if it exists) return 0;

// 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);
                fwrite(&list[i].genderValue, sizeof(list[i].genderValue), 1, file);
                fwrite(&list[i].roll_number, sizeof(list[i].roll_number), 1, file);
                fwrite(&list[i].tuition_fee, sizeof(list[i].tuition_fee), 1, file);
        }
        fclose(file);
}

// Q4:  Load file (10 points)
// This function loads data from file and build the the array of structures. 
// Use the save function given above as an example on how to write this function.
void load(char* fileName)
{
    
}

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

here is your sorting function + display function add this to your project : ---------->>>>>>>>>>>

void sort(int n){
int i,j;
struct student temp;
if(n == 1){
  for(i = 0;i<count;i++){
   for(j = i;j<count;j++){
    if(strcmp(list[i].name,list[j].name) > 0){
     strcpy(temp.name,list[i].name);
     strcpy(temp.class_standing,list[i].class_standing);
     temp.roll_number = list[i].roll_number;
     temp.genderValue = list[i].genderValue;
     temp.tuition_fee = list[i].tuition_fee;
     strcpy(list[i].name,list[j].name);
     strcpy(list[i].class_standing,list[j].class_standing);
     list[i].roll_number = list[j].roll_number;
     list[i].genderValue = list[j].genderValue;
     list[i].tuition_fee = list[j].tuition_fee;
     strcpy(list[j].name,temp.name);
     strcpy(list[j].class_standing,temp.class_standing);
     list[j].roll_number = temp.roll_number;
     list[j].genderValue = temp.genderValue;
     list[j].tuition_fee = temp.tuition_fee;
    }
   }
  }
}else if(n == 2){
  for(i = 0;i<count;i++){
   for(j = i;j<count;j++){
    if(list[i].roll_number > list[j].roll_number){
     strcpy(temp.name,list[i].name);
     strcpy(temp.class_standing,list[i].class_standing);
     temp.roll_number = list[i].roll_number;
     temp.genderValue = list[i].genderValue;
     temp.tuition_fee = list[i].tuition_fee;
     strcpy(list[i].name,list[j].name);
     strcpy(list[i].class_standing,list[j].class_standing);
     list[i].roll_number = list[j].roll_number;
     list[i].genderValue = list[j].genderValue;
     list[i].tuition_fee = list[j].tuition_fee;
     strcpy(list[j].name,temp.name);
     strcpy(list[j].class_standing,temp.class_standing);
     list[j].roll_number = temp.roll_number;
     list[j].genderValue = temp.genderValue;
     list[j].tuition_fee = temp.tuition_fee;
    }
   }
  }
}
}

void display(){
char ch = 's';
while(1){
  printf("\nPlease enter sorting method N(by name ) or R(by roll number)");
  scanf("%c",&ch);
  if(ch == 'n' || ch == 'N'){
   sort(1);
   break;
  }
  if(ch == 'r' || ch == 'R'){
   sort(2);
   break;
  }
  printf("\nthis sorting method is not defined ");
}

printf("\nThere are %d Students in the List ",count);
int i;
for(i = 0;i<count;i++){
  printf("\nName = %s \n",list[i].name);
  if(list[i].genderValue == male){
   printf("Gender = Male\n");
  }else{
   printf("Gender = Female\n");
  }
  printf("Class Standing = %s\nRoll Number = %d\nTuition Fee = %0.2f\n\n",list[i].class_standing,list[i].roll_number,list[i].tuition_fee);
}
}

Add a comment
Know the answer?
Add Answer to:
I JUST NEED HELP WITH DISPLAY PART! please help! thanks in advance // This function saves...
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
  • // 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...

  • Hello! I'm posting this program that is partially completed if someone can help me out, I...

    Hello! I'm posting this program that is partially completed if someone can help me out, I will give you a good rating! Thanks, // You are given a partially completed program that creates a list of employees, like employees' record. // Each record has this information: employee's name, supervisors's name, department of the employee, room number. // The struct 'employeeRecord' holds information of one employee. Department is enum type. // An array of structs called 'list' is made to hold...

  • // Write the compiler used: Visual studio // READ BEFORE YOU START: // You are given...

    // Write the compiler used: Visual studio // READ BEFORE YOU START: // You are given a partially completed program that creates a list of patients, like patients' record. // Each record has this information: patient's name, doctor's name, critical level of patient, room number. // The struct 'patientRecord' holds information of one patient. Critical level is enum type. // An array of structs called 'list' is made to hold the list of patients. // To begin, you should trace...

  • ASSIGNMENT DUE DATE GOT PUSHED BACK TO LATE THIS WEEK. PLEASE READ COMMENTS AND CODE BEFORE...

    ASSIGNMENT DUE DATE GOT PUSHED BACK TO LATE THIS WEEK. PLEASE READ COMMENTS AND CODE BEFORE ANSWERING CODING SECTIONS HW07 #Q1-Q5 HW08 #Q1-Q2 // READ BEFORE YOU START: // Please read the given Word document for the project description with an illustrartive diagram. // You are given a partially completed program that creates a list of students for a school. // Each student has the corresponding information: name, standard, and a linked list of absents. // Please read the instructions...

  • Convert C to C++ I need these 4 C file code convert to C++. Please Convert...

    Convert C to C++ I need these 4 C file code convert to C++. Please Convert it to C++ //////first C file: Wunzip.c #include int main(int argc, char* argv[]) { if(argc ==1){ printf("wunzip: file1 [file2 ...]\n"); return 1; } else{ for(int i =1; i< argc;i++){ int num=-1; int numout=-1; int c; int c1;    FILE* file = fopen(argv[i],"rb"); if(file == NULL){ printf("Cannot Open File\n"); return 1; } else{ while(numout != 0){    numout = fread(&num, sizeof(int), 1, file);    c...

  • Writing a program in C please help!! My file worked fine before but when I put...

    Writing a program in C please help!! My file worked fine before but when I put the functions in their own files and made a header file the diplayadj() funtion no longer works properly. It will only print the vertices instead of both the vertices and the adjacent like below. example input form commnd line file: A B B C E X C D A C The directed edges in this example are: A can go to both B and...

  • In c programming . Part A: Writing into a Sequential File Write a C program called...

    In c programming . Part A: Writing into a Sequential File Write a C program called "Lab5A.c" to prompt the user and store 5 student records into a file called "stdInfo.txt". This "stdInfo.txt" file will also be used in the second part of this laboratory exercise The format of the file would look like this sample (excluding the first line) ID FIRSTNAME LASTNAME GPA YEAR 10 jack drell 64.5 2018 20 mina alam 92.3 2016 40 abed alie 54.0 2017...

  • Using C, I need help debugging this program. I have a few error messages that I'm...

    Using C, I need help debugging this program. I have a few error messages that I'm not sure how to fix. Here is the code I have: /* * C Program to Print a Linked List in Reverse Order */ #include <stdio.h> #include <stdlib.h> struct node { int num; struct node *next; }; int main() { struct node *p = NULL; struct node_occur *head = NULL; int n; printf("Enter data into the list\n"); create(&p); printf("Displaying the nodes in the list:\n");...

  • IN C ONLY As mentioned earlier there are two changes we are going to make from...

    IN C ONLY As mentioned earlier there are two changes we are going to make from lab 5, The file you read into data structures can be any length. studentInfo array will be stored in another struct called studentList that will contain the Student pointer and current length of the list. Sometimes data can be used in structs that correlate between variables so it's convenient to store the data in the same struct. Instead of tracking a length variable all...

  • Hardware Inventory – Write a database to keep track of tools, their cost and number. Your...

    Hardware Inventory – Write a database to keep track of tools, their cost and number. Your program should initialize hardware.dat to 100 empty records, let the user input a record number, tool name, cost and number of that tool. Your program should let you delete and edit records in the database. The next run of the program must start with the data from the last session. This is my program so far, when I run the program I keep getting...

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