Starting from:

$25

COMP1400-Lab 7 GPA Survey Solved

GPA survey: Suppose that an instructor needs a piece of software to record the GPA of a class, and to find the number of students in each GPA. The software first allows the instructor to enter the number of students enrolled in the class, and then to enter the GPA of all students one by one. For each student, the input must be between 1 and 4 inclusively. Otherwise, the software displays a message as “Invalid number!” and asks for a new GPA for the same student. A sample interaction is shown below:

Sample input:                                                        Sample Output:

 

   Enter the number of students:
10
GPA of student #1 is : 
1
GPA of student #2 is :
5
Invalid number!

GPA of student #2 is :
 

2
GPA of student #3 is :
3
GPA of student #4 is :
4
GPA of student #5 is :
4
GPA of student #6 is :
2
GPA of student #7 is :
3
GPA of student #8 is :
1
GPA of student #9 is :
0
Invalid number!

GPA of student #9 is :
 

3
GPA of student #10 is :
4
 
 

The total number of students is 10.

GPA 1 --- 2 student(s)

GPA 2 --- 2 student(s)

GPA 3 --- 3 student(s)

GPA 4 --- 3 student(s)

 
 
 

Note: you should trace the GPA list just once. So, you should use an array int GPAFreq[4] to store the frequencies of each GPA from 1 to 4.

Part A: RAPTOR Exercise
a)    Understand more about RAPTOR by watching the video clip about arrays  

b)    Start RAPTOR and create the flowchart of GPA survey. To save time during software development, your algorithm needs to use random number generator to simulate the input of GPAs. For example, ”floor(Random*6)” produces a random number between 0 and 5.

c)     Save the flowchart to a file named “gpaSurvey.rap” in the working directory on the PC you are using.

 

d)    Demonstrate the gpaSurvey.rap file to GA/TAs and run with different input values. 

Suggestion: Use subcharts to help improving the readability of the flowchart.

 

Part B: C Programming Exercise
a)    Implement the algorithm as represented by “gpaSurvey.rap”, and write an equivalent C program that accomplishes what the flowchart does.

Hints: On page 173 of the textbook, an example of using random numbers is showed in the C codes of “deal.c”.

b)    Save your program to a file named “gpaSurvey.c” in the working directory on the PC you are using. 

Demonstrate the gpaSurvey.c file to GA/TAs and run with different input values

More products