Java Reference
In-Depth Information
19. a multiple-choice examination consists of 20 questions. each question has five choices,
labeled A , B , C , D , and E . the first line of data contains the correct answers to the 20
questions in the first 20 consecutive character positions. here's an example:
beCdCbaadebaCbaeddbe
each subsequent line contains the answers for a candidate. data on a line consists of a
candidate number (an integer), followed by one or more spaces, followed by the 20 answers
given by the candidate in the next 20 consecutive character positions. an X is used if a
candidate did not answer a particular question. You may assume all data is valid and stored
in a file called exam.dat . a sample line is as follows:
4325 BECDCBAXDEBACCAEDXBE
there are at most 100 candidates. a line containing a “candidate number” 0 indicates only
the end of the data.
points for a question are awarded as follows: correct answer: 4 points; wrong answer:
-1 point; no answer: 0 points.
Write a program to process the data and print a report consisting of candidate number and
the total points obtained by the candidate, in ascending order by candidate number . (this
question is in chapter 1 as well, but this time you'll solve it using objects).
20. a data file contains registration information for six courses—Cs20a, Cs21a, Cs29a, Cs30a,
Cs35a, and Cs36a. each line of data consists of a seven-digit student registration number
followed by six (ordered) values, each of which is 0 or 1 . a value of 1 indicates that the
student is registered for the corresponding course; 0 means the student is not. thus, 1 0 1
0 1 1 means that the student is registered for Cs20a, Cs29a, Cs35a, and Cs36a, but not
for Cs21a and Cs30a. You may assume that there are no more than 100 students and a
registration number 0 ends the data. Write a program to read the data and produce a class
list for each course. each list begins on a new page and consists of the registration numbers
of those students taking the course.
 
Search WWH ::




Custom Search