CS102A – Assignment 1 (Solution)

$ 20.99
Category:

Description

Background

1. When using the system, the user is required to input the following information: Student ID, Temperature, Nucleic Acid PCR test result (Y, N). Each parameter has specific requirements:
(1) Student ID: an integer number with 8-digit and the first digit can’t be “0”
(2) Temperature: a float number 35.0<T<45.0
(3) Nucleic Acid PCR test result: string with Y (finished) or N (unfinished)
If all the parameters meet the requirements above, the system will output:

Otherwise, the system will output an error message for different parameters (example):

Samples:
Input1: Read in using Scanner:

Output1:

Input2: Read in using Scanner:

Output2:

Input3: Read in using Scanner:

Output3:

2. Within 7 days of a week, if a student has not taken the Nucleic Acid PCR test for more than 2 consecutive days, or if the number of tests is less than or equal to 3 within 7 days, he/she will be noticed correspondingly. “Y” indicates that the test has been done on a certain day, and “N” indicates the test has not been done. We use a string of length 7 to indicate a student’s participation status in Nucleic Acid PCR tests in a certain week (e.g., YYYNNYY). When using the system, the user is required to input a Student ID and participation status (7-digit string). When the input meets the requirements above, the system will output:

Otherwise, the system will output:

Samples:
Input1: Read in using Scanner:

Output1:

Input2: Read in using Scanner:

Output2:

Input3: Read in using Scanner:

Output3:

3. If you want to leave the campus, you must return within 3 hours. A user should input both the time of leaving and the time of returning to the campus in the format of “hh mm ss”. Then, the system should calculate and output the duration time in the format of ” xxhxxmxxs ” that the user was outside the campus.
Samples:
Input1: Read in using Scanner:

Output1:

Input2: Read in using Scanner:

Output2:

Input3: Read in using Scanner:

Output3:

Input4: Read in using Scanner:

Output4:

4. We extend Exercise 2, and assume the COVID-19 only lasted for 4 weeks and the initial value of the student’s Score is 100. Every week, students are evaluated whether they violate the discipline according to their Nucleic Acid PCR test participation. For the first violation, 10 points will be deducted from the Score. Similarly, 15, 20 and 25 points will be deducted respectively for the second, third and fourth time violation. A student is required to input the nucleic acid participation status for 4 weeks (separate each week with a space), and then output his/her Score.
Samples:
Input1: Read in using Scanner:

Output1:

Input2: Read in using Scanner:

Output2:

Input3: Read in using Scanner:

Output3:

Reviews

There are no reviews yet.

Be the first to review “CS102A – Assignment 1 (Solution)”

Your email address will not be published. Required fields are marked *