Question

In: Computer Science

Required to develop a complete C Program (runs in Dev-C++ software) that helps to manage the records of projects in an Engineering Students Design Project competition organized by a university.

Required to develop a complete C Program (runs in Dev-C++ software) that helps to manage the records of projects in an Engineering Students Design Project competition organized by a university. The actual number of projects are unknown, but it is limited to a maximum number of 100.

Each project record contains information like Project ID, Project Title, Name of Team Members and Scores of evaluation. These project records are stored in a text file, sorted by the project id. A sample text file is given as follows,

101; Intelligent vacuum cleaner; Andrew, Bryan and Cecilia; 16;24;20;22;
102; Smart home system; Danesh and Elaine; 18;20;16;21;
104; Rubik's cube solver; Fatimah and Ganesh; 16;22;18;20;

The criteria of the project evaluation are

(a) Originality and innovativeness: 20%
(b) Scientific approach and technical design: 30%
(c) Result and project outcome: 25%
(d) Presentation and demonstration: 25%

The top three highest scores will be awarded. In addition, a Best Engineering Design award will be selected based on criteria (b).
The software reads projects’ details from file, and it should be a menu driven system having the following minimum options:

1. Add a New Project record (must keep the list ofProject Records sorted by the Project ID), and update the data file,
2. Print the summary of Project Details, i.e., Project ID, Title, Members’ Nameand Total Score, ranking from highest to lowest total score of evaluation,
3. Print the details of the winner Projects, i.e., Project ID, Title and Members’ Name,
4. Accept query of Project ID, andPrint the Score of evaluation by criteria.

Solutions

Expert Solution

// Though I have checked and compiled the program, if you found any mistake or something that I might have interpreted wrong, please comment on it.
// I will correct that as soon as possible. :)

#include
#include

//I am assuming the project ID is always a three digit number.
//if at any point in the code you see fscanf(fptr, "%c", &c);
// it is only because in the input there was an extra character that we dont need

struct node//using a linked list to input the data
{
   int ID;
   char title[50];
   char name[80];
   int a; //Originality and innovativeness
   int b; //Scientific approach and technical design
   int c; //Result and project outcome
   int d; //Presentation and demonstration
   struct node * next;
};

void insert(struct node ** head, struct node * temp)
{
   struct node * t;
   t = (struct node *)malloc(sizeof(struct node));
   t->ID = temp->ID;
  
   int i = 0;
   t->title[i] = temp->title[i];
   while(temp->title[i]!='\0')
   {
       i++;
       t->title[i] = temp->title[i];
   }
  
   i = 0;
   t->name[i] = temp->name[i];
   while(temp->name[i]!='\0')
   {
       i++;
       t->name[i] = temp->name[i];
   }
  
   t->a = temp->a;
   t->b = temp->b;
   t->c = temp->c;
   t->d = temp->d;
  
   if(*head == NULL)
   {
       *head = t;
       return ;
   }
  
   struct node * t1;
   t1 = *head;
   t->next = NULL;
   if(t1->ID > t->ID)//data is to be inserted in the head
   {
       t->next = t1;
       *head = t;
       return ;
   }
   while(t1->next!=NULL)
   {
       if(t1->next->ID > t->ID)// placing the data in the correct place
       {
           t->next = t1->next;
           t1->next = t;
           return ;
       }
       t1 = t1->next;
   }
   t1->next = t;//if the data to be inserted is at the end
}

void details(struct node * head)
{

   struct node * temp = head; //forgot to write this line. thank you for pointing it out :)
   while(temp->next!=NULL)
   {
       printf("%d; %s; %s; %d;%d;%d;%d;\n", temp->ID, temp->title, temp->name, temp->a, temp->b, temp->c, temp->d);
   }
}

void winner(struct node * head)//annouces the winner of the project
{
   struct node * winner = head;
   struct node * move = head;
   while(move->next != NULL)
   {
       if((move->a + move->b + move->c + move->d) > (winner->a + winner->b + winner->c + winner->d))
           winner = move;
       else if((move->a + move->b + move->c + move->d) == (winner->a + winner->b + winner->c + winner->d))
           if(move->b > winner->b)
               winner = move;
   }
   printf("Winner team is: %d\n", winner->ID);
   printf("Poject: %s\n", winner->title);
   printf("BY: %s\n", winner->name);
   printf("Scores: %d,%d,%d,%d ", winner->a, winner->b, winner->c, winner->d);
}

void search(struct node * head, int id)// searches for a project and prints its details
{
   struct node * temp;
   temp = head;
   while(temp->ID != id)
       temp = temp->next;
   if(temp == NULL)
   {
       printf("project ID not found");
       return;
   }
   printf("%d; %s; %s; %d;%d;%d;%d;", temp->ID, temp->title, temp->name, temp->a, temp->b, temp->c, temp->d);
}

void print()
{
   printf("MENU:\n");
   printf("enter a number for that option");
   printf("1. Add a New Project record(in the correct format)");
   printf("2. Print the summary of Project Details");
   printf("3. Print the details of the winner Projects");
   printf("4. Query by Project ID");
   printf("5. EXIT.");
}

int main(void)
{
   FILE *fptr;
   char filename[20];
   struct node * head;
   printf("Enter the filename to be opened \n");
   fptr = fopen(filename, "r");//opening the file
   if(fptr == NULL)
   {
       printf("no such file found. ERROR!");
       exit(0);
   }
   struct node * temp;
   temp = (struct node *)malloc(sizeof(struct node));
   char c;
   int i;
   int a;
   while(fscanf(fptr, "%c", &c))//fscanf returns -1 when there is no other object data left to scan or when we reached the end of file.
   {
       fscanf(fptr, "%d", &a);
       temp->ID = a + ((int)c - 48)*100;//entering the correct value in the node
       fscanf(fptr, "%c", &c);//ignoring the next char ";"
       fscanf(fptr, "%c", &c);//ignoring the next char " "
       i = 0;
       while(c!=';')//entering the value for project title
       {
           fscanf(fptr, "%c", &c);
           if(c!=';')
               temp->title[i] = c;
           else temp->title[i] = '\0';
           i++;
       }
      
       fscanf(fptr, "%c", &c);//ignoring the next char " "
       i = 0;
       while(c!=';')//entering the value for project student's names
       {
           fscanf(fptr, "%c", &c);
           if(c!=';')
               temp->name[i] = c;
           else temp->name[i] = '\0';
           i++;
       }
      
       fscanf(fptr, "%d", &a);
       temp->a = a;
       fscanf(fptr, "%c", &c);
      
       fscanf(fptr, "%d", &a);
       temp->b = a;
       fscanf(fptr, "%c", &c);
      
       fscanf(fptr, "%d", &a);
       temp->c = a;
       fscanf(fptr, "%c", &c);
      
       fscanf(fptr, "%d", &a);
       temp->d = a;
       fscanf(fptr, "%c", &c);
      
       insert(&head, temp);
   }
   fclose(fptr); // closing the file
  
   print();
   int b;
   scanf("%d", &b);
   while(b!=5)
   {
       if(b == 1)
       {
           fscanf(fptr, "%d", &a);
           fscanf(fptr, "%c", &c);//ignoring the next char ";"
           fscanf(fptr, "%c", &c);//ignoring the next char " "
           i = 0;
           while(c!=';')//entering the value for project title
           {
               fscanf(fptr, "%c", &c);
               if(c!=';')
                   temp->title[i] = c;
               else temp->title[i] = '\0';
               i++;
           }
          
           fscanf(fptr, "%c", &c);//ignoring the next char " "
           i = 0;
           while(c!=';')//entering the value for project student's names
           {
               fscanf(fptr, "%c", &c);
               if(c!=';')
                   temp->name[i] = c;
               else temp->name[i] = '\0';
               i++;
           }
          
           fscanf(fptr, "%d", &a);
           temp->a = a;
           fscanf(fptr, "%c", &c);
          
           fscanf(fptr, "%d", &a);
           temp->b = a;
           fscanf(fptr, "%c", &c);
          
           fscanf(fptr, "%d", &a);
           temp->c = a;
           fscanf(fptr, "%c", &c);
          
           fscanf(fptr, "%d", &a);
           temp->d = a;
           fscanf(fptr, "%c", &c);
          
           insert(&head, temp);
       }
       if(b == 2)
       {
           details(head);
       }
       if(b == 3)
       {
           winner(head);
       }
       if(b == 4)
       {
           int id;
           printf("Enter the project ID: ");
           scanf("%d", &id);
           search(head, id);
       }
       print();
   }
   return 0;
}


Related Solutions

Discuss steps required to manage a software engineering project.
Discuss steps required to manage a software engineering project.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT