You must design a COVID-19 screening application for your campus. The guards at each gate will screen the students . The capabilities and features of the application should include a choice between the following functions:
1. A screening survey which will allow guards to record the students’ screening data.
*No student should be allowed access to the campus after 12h00 in the afternoons regardless of whether capacity has been reached or not.
*If a student’s temperature is 38 degrees or more, they will not be allowed entry into the campus.
1.Make use of parrel arrays and write the pseudocode that will accurately represent the application you are designing.
pseudocode
Start
Declare variable n of type integer
Declare array names of type String
Declare array studentTimeAccessCampus of type String
Declare array studentTemperatures of type String
Declare variable counter of type integer
Get the number of students
for i=0 to n step 1
Get the student name from the user
Add name to the array names
Get hour for the student from the user
Get minutes for the student from the user
Get temperature for the student from the user
if hour>=1 and minutes>=0 and hour<12 and minutes<59 and temperature<38
Add hour and minutes to the array studentTimeAccessCampus
Add temperature to the array studentTemperatures
counter=counter+1
Print message: "This students are allowed entry into the campus: "
for i=0 to counter step 1
Print the student name
Print the student time
Print the student temperature
Stop
Java code:
import java.util.Scanner;
public class Q194566 {
public static void main(String[] args) {
// Scanner object
Scanner keyboard = new Scanner(System.in);
try {
System.out.print("Enter the number of students: ");
int n= keyboard.nextInt();
//Declare arrays
String names[]=new String[n];
String studentTimeAccessCampus[]=new String[n];
int studentTemperatures[]=new int[n];
int counter=0;
for(int i=0;i<n;i++) {
keyboard.nextLine();
// Get the student name from the user
System.out.print("Enter the student name "+(i+1)+": ");
names[counter]= keyboard.nextLine();
System.out.print("Enter hour for the student "+(i+1)+": ");
int hour= keyboard.nextInt();
System.out.print("Enter minutes for the student "+(i+1)+": ");
int minutes= keyboard.nextInt();
System.out.print("Enter temperature for the student "+(i+1)+": ");
int temperature = keyboard.nextInt();
if(hour>=1 && minutes>=0 && hour<12 && minutes<59 && temperature<38) {
studentTimeAccessCampus[counter]=String.format("%d:%d",hour,minutes);
studentTemperatures[counter]=temperature;
counter++;
}
}
System.out.println("\nThis students are allowed entry into the campus: ");
for(int i=0;i<counter;i++) {
System.out.println("The student name: "+names[i]);
System.out.println("The student time: "+studentTimeAccessCampus[i]);
System.out.println("The student temperature: "+studentTemperatures[i]+"\n");
}
} catch (Exception e) {
// Display the error message:
System.out.print("Incorrect value");
}
// close Scanner
keyboard.close();
}
}
Example:
Comments
Leave a comment