C代写:COS10007 Developing Technical Software request1

Instructions

  1. This request contains 4 questions. Question 1 carries 14 marks. Question 2,3, & 4 carries 7 marks each
  2. Pseudo Code is mandatory for all the programs
  3. Submit only one document (Single word document)
  4. Copy and paste your code into word document
  5. Copy and paste the screen shot of the output window in the same word document
  6. Use only .doc, .docx extensions – no other format will be accepted for marking
  7. Marks will be given for proper indentation and comments

Qn 1

A gaming company consists of many kind of games and each customer orders online to buy a game. The gaming company will search for the specific game upon customers request in the order of first come first served basis. The gaming company has the following requirements.

  1. There are many kinds of games available (at least ten). They may have more than one game for each genre
  2. The customers list is organised in a Queue as a first come first served basis
  3. The gaming company should be able to retrieve the data of the last sold games.

Your program should consist of a linked list with the following features

  1. Insertion at the head
  2. Insertion at the tail
  3. Deletion from the head
  4. Deletion form the tail
  5. Deleting specific element from the list

The next part should be implementing a Stack inherited from the above linked list with the following features

  1. Pop
  2. Push
  3. Top

The next part should be implementing a Queue inherited from the above linked list with the following features

  1. Enqueue
  2. Dequeue
  3. Top

The program flow is as follows:

The games should be saved in a linked list. The list of games ordered by customers should be saved in a queue. You should take the order from the beginning of the queue and search for it in the linked list then delete it and put this game name in a stack to be able to retrieve in the last sold game.

Qn 2

Write a C program that calculates the time difference between the system time and the users input time. For example if the user input is Brisbane time, the program should give the difference in hrs:mins:secs between the system time and Brisbane time. The program should use “structures” and both system time and user input time should be stored in structure variables.

Qn 3

Create a linked list using the following structure

1
2
3
4
5
6
struct studentid {
int id;
struct studentid *next;
};
typedef struct studentid STUDENTID;
typedef STUDENTID * STUDENTIDPtr;

You have to create a linked list manually similar to week 4 Qn2 lab exercise. There should be five nodes in the linked list and the elements should be the last 5 digits of your student id. One digit will go to one node and the node insertion should happen in order similar to week 4 Qn 1.

Eg: Assume your student id is 100989674, take the last five digits which is 89674 so the insertion order is

1
2
3
4
5
6
7
8
9
10
11
12
13
14
newptr=……..malloc(STUDENTID);
newptr->id=8;
.
.
.
9
.
.
6
.
7
.
.
4

and the final linked list should be in ascending order as shown below.

1
2
3
4
5
6
graph LR
4-->6
6-->7
7-->8
8-->9
9-->NULL

Qn 4

Use the following structure for this task.

1
2
3
4
5
struct student{
char name[30];
int id;
float mark;
};

Declare an array named studentArray of the structure type shown above, the size of the array is
limited to maximum 100.

The main() function handles all interactions with the user and other functions:

  • It displays an appropriate welcoming message introducing the program.
  • Calls a function named readFile() which opens the text file grades.txt for reading and stores all of the students details from the file to an array named studentArray. The grades.txt has three columns, first column contains name, second column contains id and third column contains mark. The readFile()function has two parameters: one for receiving the file variable and one for the array, both receiving arguments passed by reference.
  • It then repeatedly calls the menu() function to display user options, get the user selection returned by the menu() function, use a switch statement to process user request by calling appropriate function(s)
  • It displays the result with an appropriate message after processing user request.
  • It displays a goodbye message when the user selects the Quit option from the menu and terminates the program.

The menu() function has no parameters. When called, it displays a menu of 4 options allowing the user to select one and returns this option to the calling main() function.

The options displayed should be:

  1. Display students’ details
  2. Calculate average of all students’ marks
  3. Add new student to the record
  4. Quit program
  • Option (1) will use a function called displayStudents()called from the main() to display the contents of the studentArray array on the screen in an appropriate format. The displayStudents() function has two parameters: the array and the size of the array.
  • Option (2) will use a function called calculateAverage() which is designed to calculate the average value of all marks in studentArray and return the result to the main() function which will then display it with an appropriate message. This function also has two parameters: the array and the size of the array.
  • Option (3) will first use a function called updateFile() which will open the file in append mode, prompt the user for new student’s name, id and mark, and then write the new data at the end of the file using the same format as the original file. It will then the call the readFile() function used in the beginning of the program again to read the contents of the updated file and repopulate the studentArray.
  • Option (4) will terminate the program after displaying an appropriate goodbye message.
  • Text file sample.

image