Comment on Tutorial - Sorting an integer array in C By Ignatius



Comment Added by : Lauren

Comment Added at : 2013-04-18 14:45:25

Comment on Tutorial : Sorting an integer array in C By Ignatius
Can someone help me please?


Imagine that some students each sit 4 examinations, receiving a mark for each exam expressed as a
positive whole number (nothing to the right of the decimal point) as a percentage (i.e somewhere in the
range 0 to 100%).
 Your customer would like to study such examination results by using a program that determines,
for each exam, how many students scored a mark between 0-9, how many between 10-19, how
many between 20-29 and so on.
 Also the customer would like to be able to write to a computer file a list of all students and marks
awarded for any one particular exam, this list being arranged in mark order (i.e. the person with
the highest mark being listed first, the person with the next highest listed second and so on.)
Requirements specification:
1) To read in all candidates' results from a file called “datafile.txt” which your program should
expect to find in your drive U: in the root (outer most) folder (that is location U:\datafile.txt). This
file will consist of each candidate's results listed on a separate line, in a file using comma separated
format. An individual candidate's results will be made up as follows: first that candidate’s 6-digit
registration number (in other words identification number) then a set of four integer numbers
representing the mark which that candidate achieved in each of the four exams. Each line in the file
will therefore consist of a candidate's Registration Number (expressed as a 6 digit ASCII decimal
number) followed by a comma character "," then that candidate's mark in exam 1 (expressed as a
whole number as a decimal in the range 0 to 100), and then another comma character "," followed
by their mark in exam 2, another comma, followed by their mark in exam 3, another comma,
followed by their mark in exam 4 and finally an end of line character ('\n'). And so on for each
candidate.
An example of the contents of 'datafile.txt' might be:
105683,23,65,0,100
105475,96,72,35,61
105286,23,45,15,86
104762,23,17,5,56
So candidate “105286” scored 23 in exam one, 45 in exam two, 15 in exam three and 86 in exam
four. (Some example data files have been created for you and saved on the internet. To download the
example files go onto the internet to the following page and download them from there:
http://www.peter-judd.staff.shef.ac.uk/c-stuff/c-downloads.html
And look for section Examples for Assessed Exercise 2 in 2013 near the bottom.
You could copy these files into your own U: drive’s root folder \ so that you can use them to test
your program). You can read and edit (or indeed create your own) such files using the Dev-C editor
or even Windows' Notebook application, as these data files are simply ASCII text readable files.
2) The program should be designed to accept result files with any number of candidates within the range
1 to 40 students (inclusive). Having read in the results file, it should determine and display, for each
particular exam, how many candidates scored a mark in the range 0-9, 10-19, 20-29, 30-39, 40-49,
50-59, 60-69, 70-79, 80-89, 90-100. So, for the example datafile.txt shown above, your
program would display:
An example of what the computer screen might display might show:
Exam1 Exam2 Exam3 Exam4
0-9 0 0 2 0
10-19 0 1 1 0
20-29 3 0 0 0
30-39 0 0 1 0
40-49 0 1 0 0
50-59 0 0 0 1
60-69 0 1 0 1
70-79 0 1 0 0
80-89 0 0 0 1
90-100 1 0 0 1
C:\Users\Peter\Desktop\C-stuff\assess-2-2013.doc 3 ( Peter Judd/University of Sheffield 1999-2013) 06/03/2013
Don't forget to allow the user to be able to view all the data presented on the screen (assume the user
can only see 25 lines at a time) before continuing.
3) Next the program should create a new output file and write the results for just one of the four exams
into this file (after first asking the user to choose which set of exam results to place in the file). These
results should be sorted in descending order of mark magnitude (i.e. highest first).
 The program will first need to ask the user to choose which of the four exams is to have its results
written to this new file.
 The new file must be named "dataout.txt" and should reside in the same place as the input
file "datafile.txt" used earlier (i.e. in the U: drive root folder U:\datafile.txt)
 Each candidate's result must appear on its own line, beginning with the candidate's Registration
Number (expressed as a 6 digit ASCII decimal integer number) just as it appeared in the input
file, then a comma (to act as a separator) and then the candidate's mark in the chosen exam.
There should be no padding spaces (or other) characters in this file.
Let's consider this program processing an example input file such as the "datafile.txt"
mentioned earlier and lets assume the user selected exam number 3 to have its results copied to the
output file, that file should now contain:
An example of what 'dataout.txt' might contain if user selected exam number 3:
105475,35
105286,15
104762,5
105683,0


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. I find dis site very educating
View Tutorial          By: Kensho at 2009-05-09 05:18:57

2. how can get ip url...?
View Tutorial          By: arjuna at 2011-11-23 03:31:46

3. can u access by a tutorial by using java script
View Tutorial          By: Benjtaz at 2011-07-11 06:22:16

4. Hello,

your solution is kinda overk

View Tutorial          By: Hdm-Student at 2010-06-16 08:10:51

5. Hi i am sanjay ,
I got the exact difference

View Tutorial          By: Sanjay Patel at 2012-05-06 11:36:00

6. Great!! Many thanks!
View Tutorial          By: Louis at 2013-06-01 23:16:41

7. @pooja: this method should work, although i'm sure
View Tutorial          By: Anush at 2012-07-16 08:30:58

8. great answer...
View Tutorial          By: nagi ponnagani at 2011-04-29 14:11:21

9. this is very good example.
View Tutorial          By: jyoti raman ray at 2010-10-13 22:17:09

10. nice
View Tutorial          By: udhay at 2011-04-01 02:48:25