[Solved] COMP1400 Lab7-Working with arrays

$25

File Name: COMP1400_Lab7-Working_with_arrays.zip
File Size: 310.86 KB

SKU: [Solved] COMP1400 Lab7-Working with arrays Category: Tag:
5/5 - (1 vote)

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

  1. Understand more about RAPTOR by watching the video clip about arrays
  2. 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.
  3. Save the flowchart to a file named gpaSurvey.rap in the working directory on the PC you are using.
  1. 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

  1. 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.

  1. Save your program to a file named gpaSurvey.c in the working directory on the PC you are using.
  2. Demonstrate the gpaSurvey.c file to GA/TAs and run with different input values.

EVALUATION:

You need to show your GA/TA the complete programs at the end of this lab, or at the beginning of your next lab. The marks you will receive for this lab are made of two parts: Lab work marks 10 and attendance marks 5. Total 15 marks.

Lab Work Mark: Your C code will be evaluated based on your solutions for the problems based on the following scheme:

  1. Does the code run and meet specifications?
    • Is input adequate and input data type properly validated?
    • Is processing adequate?
    • Is output correct and adequate?
    • Is the code compliable? Is the code run properly?
  1. Is the code properly commented?
    • Is the program title, programmers first and last name, and the date posted at the top in a multi-line comment?
    • Is each significant step of the program properly commented?
    • Are comments added to clarify details?
    • Are comments clear, accurate, neatly formatted, and have no misspellings?
  1. Is the code properly formatted?
    • Are blocks of code indented according to their parent-child relationship?
    • Do curly braces line up vertically?
    • Is there an empty line between significant steps (blocks) of the program?
    • Is the width of the code contained within a reasonable limit so that minimal horizontal scrolling is required (with 800 x 600 monitor resolution), and there is minimal linewrapping when printed?
    • Is camel-case notation used for variable, e.g. employeeLastName?

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] COMP1400 Lab7-Working with arrays
$25