1. Homepage
  2. Programming
  3. COMP20005 Intro. to Numerical Computation in C Assignment 1: Medal winners

COMP20005 Intro. to Numerical Computation in C Assignment 1: Medal winners

Engage in a Conversation
UnimelbCOMP20005Intro. to Numerical Computation in CCMedal winners

School of Computing and Information Systems CourseNana.COM

comp20005 Intro. to Numerical Computation in C Semester 1, 2024 CourseNana.COM

Assignment 1 CourseNana.COM

Learning Outcomes CourseNana.COM

In this project you will demonstrate your understanding of loops, if statements, functions, and arrays; writing a program that first reads some numeric data and then performs a range of processing tasks on it. You may also make use of structures if you wish (Chapter 8). But there is no requirement for you to make use of struct types, and the required tasks can equally well be carried out using a small number of one-dimensional arrays. CourseNana.COM

Background and Task CourseNana.COM

Imagine that the University of Melbourne has won the rights to host the first International Lecturing Olympics in 2024, and that a program is needed to read the judges’ (that is, students’) scores for each class given by each academic contender, and from them determine the medal winners. CourseNana.COM

Each input line to that scoring program will look like this: CourseNana.COM

    A 5.5 6.6 5.2 5.8 8.1 7.2 8.0

in which: CourseNana.COM

  • Thefirstinputvalueoneachlineisasinglecharacter(intheexample,’A’)thatisacodethatidentifies the lecturer that gave this class, and is to be stored as an int after being read into a char variable using scanf("%c",...); CourseNana.COM

  • All remaining values in each line are student scores (between 0.0 and 10.0) from the students that attended that class (in the example there are seven such scores), separated by single spaces, and are to be stored as double and read using scanf("%lf",...); and CourseNana.COM

  • The last score in each line is immediately followed by a newline character. CourseNana.COM

    The input file consists of multiple such lines, one per class given during the Olympic competition. All input lines will be formatted exactly as shown, but with varying numbers of scores; and you do not need to try and anticipate variations to the input format, or to carry out any data validation. Several sample input files are linked from the LMS Assignment 1 page, and you can also create your own. CourseNana.COM

To compute the score for each class your program needs to implement the following steps: CourseNana.COM

  • Input lines with fewer than three scores are discarded, and it is as if that class never happened; else CourseNana.COM

  • The two smallest scores in each line are identified and discarded; CourseNana.COM

  • The remaining scores are summed; and then CourseNana.COM

  • The per-class “adjusted average score” is computed by dividing that sum by the original number of CourseNana.COM

    scores that were provided. CourseNana.COM

    The example input line shown above would have the 5.2 and the 5.5 discarded, since they are the two lowest scores, and then the calculation (6.6 + 5.8 + 8.1 + 7.2 + 8.0)/7 = 5.100 would be done. This adjusted average calculation discounts the scores for small classes relative to large classes, compensating for the natural lecturing advantage of small classes. CourseNana.COM

    Each competing academic gives several lectures through the course of the competition, with each of their classes recorded as an input line using their one-character code. The per-class scores for each academic are then collated into an overall per-lecturer score using a very similar computation: CourseNana.COM

  • Lecturers with fewer than three per-class scores are discarded, and it is as if those lecturers didn’t enter the competition; else CourseNana.COM

  • The two smallest per-class scores for each lecturer are identified and discarded; CourseNana.COM

  • The remaining per-class scores are summed; and then CourseNana.COM

  • The per-lecturer score is computed by dividing that sum by the number of per-class scores associated CourseNana.COM

    with that lecturer. CourseNana.COM

    This scoring regime allows each lecturer to have two “off” days when they need to present important but boring material (such as the scope rules in C); and rewards lecturers who take more (and better) classes. For example, suppose that lecturer ’A’ gave a total of six lectures during the Olympics, and that there are thus six input lines that start with ’A’. Those six lines (see file test1.txt) translate into a set of five per-class scores, because one of the six classes doesn’t have enough student scores to be used: CourseNana.COM

input lines (file test1.txt) CourseNana.COM

score computation CourseNana.COM

(6.6+5.8+8.1+7.2+8.0)/7 9.9/3
discarded (8.7+6.2+7.8+7.7+9.1+8.9)/8 (5.5 + 5.6)/4 CourseNana.COM

(6.1 + 8.3 + 8.1)/5 CourseNana.COM

per-class score CourseNana.COM

5.100 3.300 6.050 2.775 4.500 CourseNana.COM

A 5.5
A 9.9
A 3.7
A 4.4
A 3.8
A 2.2
6.6 5.2 5.8
9.8 9.2
8.7 6.2 7.8
3.8 5.5 5.6
6.1 8.3 5.4

8.1 7.2 8.0 CourseNana.COM

7.7 9.1 5.1 8.9
8.1

Then, from the five per-class scores, the two smallest values get dropped and lecturer ’A’ gets a per- lecturer score of (5.100 + 6.050 + 4.500)/5 = 3.130 (to three decimals). Note the similarity of the per-class and per-lecturer computations, and take the hint – maybe there is a function to be developed for that task. CourseNana.COM

The per-lecturer scores are then basis for the final ranking. The lecturer with the highest score is awarded the gold medal, and the next two highest per-lecturer scores receive the silver and bronze medals. (But note that score ties must be checked, see Stage 3.) CourseNana.COM

You should assume that (and use #define statements for) the following limits on the input: CourseNana.COM

  • There will be at most 26 competitors, with individual lecturer codes given by the single characters from ’A’ (which could be “Alistair”, perhaps) through to ’Z’ (could be “Zoe”). CourseNana.COM

  • There will be at most 50 scores in any given input line (students who watch the lectures from home are not eligible to cast votes); CourseNana.COM

  • There will be at most 500 lectures delivered in total (across all competitors) as part of the Olympic competition. CourseNana.COM

    Stage 1 – Reading the Data (marks up to 8/20) CourseNana.COM

    The first task is reading all the input data, and processing it into an array of per-class scores, with a lecturer code associated with each such score. As a check that you have read accurately, you should also print the last set of input values that were read and (if it has one) the corresponding per-class score. For the six lines shown above (the input file test1.txt), the required output for this stage is: CourseNana.COM

        mac: ass1-soln < test1.txt
        Stage 1, 6 class lines in input
        Stage 1, 5 per-class adjusted scores retained
        Stage 1, last line of input was
    
            "A: 2.2 6.1 8.3 5.4 8.1"
        Stage 1, last per-class score was 4.500
    

    If the last input score set contains fewer than three values, the final Stage 1 output line is not printed. 2 CourseNana.COM

Note that input must be read from stdin via “<” input redirection at the shell level. You must not make use of the file manipulation functions described in Chapter 11. No prompts are to be written. CourseNana.COM

To obtain full marks you need to exactly reproduce the required output lines. Further example input files and the required outputs can be found linked from the Assignment 1 LMS page. CourseNana.COM

You may do your programming in Grok, and an “Assignment 1” project will be released shortly that includes the skeleton code and the test files. You should look at the handout “Running Programs in a Shell Within Grok”, linked from the Assignment 1 LMS page if you wish to do this. You should also read the instructions in the left-hand pane of the Grok “Assignment 1” project, to understand the automated testing and checking options (via diff) that are being used. CourseNana.COM

Or you may find it more convenient to use a separate programming environment on your computer, and download the skeleton program, test files, and expected output files to it. Information about this option is also available on the LMS. CourseNana.COM

Stage 2 – Aggregate by Lecturer (marks up to 16/20) CourseNana.COM

Ok, next you need to compute the per-lecturer averages, using the array of per-class scores (and the parallel array of associated lecturer codes) that you constructed in Stage 1. There are several input/output examples linked from the LMS Assignment 1 page that show what is required, and you should study them carefully. Note the row ordering: each lecturer has their overall adjusted average calculated and presented in the order in which they first gave rise to retained per-class scores. CourseNana.COM

Stage 3 – Gold, Silver, Bronze! (marks up to 20/20) CourseNana.COM

The final task is to determine the medal winners. The easiest way to do this is to sort the array of per- lecturer adjusted averages (from Stage 2) into decreasing order, and print the first three. You may use insertion sort, but be sure to also swap around the lecturer code that is associated with each per-lecturer score. Two helpful functions have been provided in the skeleton code. CourseNana.COM

Then the first (normally) three entries can then be printed as being medal winners, taking them from the beginning of the array. But if there are fewer than three lecturers with per-lecturer scores, fewer than three lines will be printed. You also need to be careful of ties, and if there are any further lecturers who get the same score (to three decimal places) as the third placed lecturer, they must also be reported. A human overseer will then determine what mixture of medals will be awarded in such cases. For example, if (to three decimal places) four lecturers all get the same top score, there might be four gold medals. CourseNana.COM

There is a further function provided in the skeleton code to help with this task, and file test4.txt provides an input example and shows what must be reported. CourseNana.COM

Finally, whatever you do, don’t overlook the final output line after the Stage 3 outputs, it is also required! CourseNana.COM

Refinements to the Specification CourseNana.COM

There may be areas where this specification needs clarification or even correction, and you should check the “Assignment 1” Ed Discussion page regularly for updates to these instructions. There is also a range of information linked from the “Assignment 1” LMS page that you need to be aware of. CourseNana.COM


CourseNana.COM

Get in Touch with Our Experts

WeChat WeChat
Whatsapp WhatsApp
Unimelb代写,COMP20005代写,Intro. to Numerical Computation in C代写,C代写,Medal winners代写,Unimelb代编,COMP20005代编,Intro. to Numerical Computation in C代编,C代编,Medal winners代编,Unimelb代考,COMP20005代考,Intro. to Numerical Computation in C代考,C代考,Medal winners代考,Unimelbhelp,COMP20005help,Intro. to Numerical Computation in Chelp,Chelp,Medal winnershelp,Unimelb作业代写,COMP20005作业代写,Intro. to Numerical Computation in C作业代写,C作业代写,Medal winners作业代写,Unimelb编程代写,COMP20005编程代写,Intro. to Numerical Computation in C编程代写,C编程代写,Medal winners编程代写,Unimelbprogramming help,COMP20005programming help,Intro. to Numerical Computation in Cprogramming help,Cprogramming help,Medal winnersprogramming help,Unimelbassignment help,COMP20005assignment help,Intro. to Numerical Computation in Cassignment help,Cassignment help,Medal winnersassignment help,Unimelbsolution,COMP20005solution,Intro. to Numerical Computation in Csolution,Csolution,Medal winnerssolution,