Answer to Question #194888 in Java | JSP | JSF for Ray

Question #194888

You must design a COVID-19 screening application for your campus. The guards at each gate will screen the students and enter their details on the application. :

1. A screening survey which will allow guards to record the students’ screening data.

2. Searching for a student’s details and status.

Technical Requirements:

*The application should make use of Parallel arrays that will hold the details of the student as it is entered along with their status (admitted/not admitted). No more than 300 students will be allowed on campus .

*No student should be allowed access to the campus after 12h00 in the afternoon.

* If a student’s temperature is 38 degrees or more, they will not be allowed entry into the campus.

1.Without writing the pseudocode say what will be in which module(”fillArray()”,”sortArray()”,”displayArray()” )with the information provided above.


1
Expert's answer
2021-05-18T15:07:32-0400


import java.util.Scanner;


public class Q194888 {
	// Scanner object
	private static Scanner in = new Scanner(System.in);


	/**
	 * The start point of the program
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		
		System.out.print("Enter the number of students: ");
		int n= in.nextInt();
		// Declare arrays
		String names[] = new String[300];
		String studentTime[] = new String[300];
		int studentTemperatures[] = new int[300];


		int numberStudents = fillArray(names, studentTime, studentTemperatures, n);
		sortArray(names, studentTime, studentTemperatures, numberStudents);
		displayArray(names, studentTime, studentTemperatures, numberStudents);
		in.nextLine();
		System.out.print("Enter the student name to search: ");
		String nameSearch = in.nextLine();
		boolean studentExist=false;
		for (int i = 0; i < numberStudents; i++) {
			if(nameSearch.compareToIgnoreCase(names[i])==0) {
				System.out.println("The student name: " + names[i]);
				System.out.println("The student time: " + studentTime[i]);
				System.out.println("The student temperature: " + studentTemperatures[i] + "\n\n");
				studentExist=true;
			}
		}
		if(!studentExist) {
			System.out.println("The student does not exist.\n\n");
		}
		// close Scanner
		in.close();
	}


	/**
	 * Fill arrays
	 * 
	 * @param names
	 * @param studentTime
	 * @param studentTemperatures
	 * @param n
	 * @return
	 */
	private static int fillArray(String names[], String studentTime[], int studentTemperatures[], int n) {
		int numberStudents = 0;
		for (int i = 0; i < n; i++) {
			in.nextLine();
			System.out.print("Enter the student name " + (i + 1) + ": ");
			names[numberStudents] = in.nextLine();
			System.out.print("Enter hour for the student " + (i + 1) + ": ");
			int hour = in.nextInt();
			System.out.print("Enter minutes for the student " + (i + 1) + ": ");
			int minutes = in.nextInt();
			System.out.print("Enter temperature for the student " + (i + 1) + ": ");
			int temperature = in.nextInt();
			if (hour >= 1 && minutes >= 0 && hour < 12 && minutes < 59 && temperature < 38) {
				studentTime[numberStudents] = String.format("%d:%d", hour, minutes);
				studentTemperatures[numberStudents] = temperature;
				numberStudents++;
			}
		}
		return numberStudents;
	}
	/**
	 * sort arrays by student temperatures
	 * @param names
	 * @param studentTime
	 * @param studentTemperatures
	 * @param numberStudents
	 */
	private static void sortArray(String names[], String studentTime[], int studentTemperatures[], int numberStudents) {
		for (int i = 0; i < numberStudents - 1; i++) {
			for (int j = 0; j < numberStudents - i - 1; j++) {
				if (studentTemperatures[j] > studentTemperatures[j + 1]) {
					// sort by student temperatures
					int temp = studentTemperatures[j];
					studentTemperatures[j] = studentTemperatures[j + 1];
					studentTemperatures[j + 1] = temp;
					
					String tempName = names[j];
					names[j] = names[j + 1];
					names[j + 1] = tempName;
					
					String tempStudentTime = studentTime[j];
					studentTime[j] = studentTime[j + 1];
					studentTime[j + 1] = tempStudentTime;
				}
			}
		}
	}


	/**
	 * Display arrays
	 * 
	 * @param names
	 * @param studentTime
	 * @param studentTemperatures
	 * @param numberStudents
	 */
	private static void displayArray(String names[], String studentTime[], int studentTemperatures[],
			int numberStudents) {


		System.out.println("\nThis students are allowed entry into the campus: ");
		for (int i = 0; i < numberStudents; i++) {
			System.out.println("The student name: " + names[i]);
			System.out.println("The student time: " + studentTime[i]);
			System.out.println("The student temperature: " + studentTemperatures[i] + "\n\n");
		}
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS