Answer to Question #174490 in Java | JSP | JSF for Jean Claude

Question #174490

A.) A module is required to enable lecturers to easily identify the highest and lowest performing students in their courses. As the lead programmer, write a java program to achieve this. Your program should have the following features: Each correctly implemented feature earns you 3 marks.


i. The program should make use of a sentinel to control the number of grades entered.


ii. Total Number of grades entered


iii. The average of the grades


iv. Number of students that achieved a grade of 80 and above


v. Number of students that achieved a grade of 50 and below


B.) An algorithm is a procedure for solving a problem in terms of the actions to execute and the order in which these actions execute. Write an algorithm for the implementation of the sentinel control in Question A Sub Question I above.


C.) For larger datasets, a linear search may be inadequate or perhaps inefficient. What other search method can be employed to return the maximum number from a set of elements in an array. Explain your answer.


1
Expert's answer
2021-04-02T11:53:45-0400
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {


	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		Scanner scanner = new Scanner(System.in);
		int condition = 0;
		List<Student> group = new ArrayList<>();
		List<Student> bestStudent = new ArrayList<>();
		List<Student> uninsured = new ArrayList<>();


		do {
			Student student = new Student();
			System.out.println("Please provide the student id and press Enter:");
			int studentId = input.nextInt();
			student.setId(studentId);
			System.out.println("Please provide the student last name and press Enter:");
			String studentLastName = scanner.nextLine();
			student.setName(studentLastName);
			System.out.println("Now provide students 3 marks and press Enter:");
			System.out.println("Please provide the student first mark and press Enter:");
			int firstMark = input.nextInt();
			student.setFirstMark(firstMark);
			System.out.println("Please provide the student second mark and press Enter:");
			int secondMark = input.nextInt();
			student.setSecondMark(secondMark);
			System.out.println("Please provide the student third mark and press Enter:");
			int thirdMark = input.nextInt();
			student.setThirdMark(thirdMark);
			student.calculateAverrage();
			group.add(student);
			System.out.println("One more  entering of Student print 1 if yes or 2 if no and press Enter:");
			condition = input.nextInt();
		} while (!(condition == 2));
		System.out.println("List of students:");
		for (Student st : group) {
			System.out.println(st);
			if (st.getAverrage() >= 80) {
				bestStudent.add(st);
			} else if (st.getAverrage() <= 50) {
				uninsured.add(st);
			}
		}
		System.out.println();
		System.out.println("Number of students that achieved a grade of 80 and above:");
		System.out.println();
		for (Student students : bestStudent) {
			System.out.println(students);
		}
		System.out.println();
		System.out.println("Number of students that achieved a grade of 50 and below:");
		for (Student students : uninsured) {
			System.out.println(students);
		}
		input.close();
		scanner.close();
	}
	/*
	 * For sorting big list of students you should implement collections.Arrays non
	 * good solution.I use for each loop and if-else statement.Streams API also good
	 * solving
	 */
}
public class Student {
	private int id;
	private String name;
	private int firstMark;
	private int secondMark;
	private int thirdMark;
	private int averrage;


	public Student() {


	}


	public Student(int id, String name, int firstMark, int secondMark, int thirdMark, int averrage) {
		this.id = id;
		this.name = name;
		this.firstMark = firstMark;
		this.secondMark = secondMark;
		this.thirdMark = thirdMark;


	}


	public int getId() {
		return id;
	}


	public void setId(int id) {
		this.id = id;
	}


	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	public int getFirstMark() {
		return firstMark;
	}


	public void setFirstMark(int firstMark) {
		this.firstMark = firstMark;
	}


	public int getSecondMark() {
		return secondMark;
	}


	public void setSecondMark(int secondMark) {
		this.secondMark = secondMark;
	}


	public int getThirdMark() {
		return thirdMark;
	}


	public void setThirdMark(int thirdMark) {
		this.thirdMark = thirdMark;
	}


	public int getAverrage() {
		return averrage;
	}


	public void setAverrage(int averrage) {
		this.averrage = averrage;
	}


	@Override
	public String toString() {
		return "Student [id=" + id + ", name=" + name + ", firstMark=" + firstMark + ", secondMark=" + secondMark
				+ ", thirdMark=" + thirdMark + ", averrage=" + averrage + "]";
	}


	public void calculateAverrage() {
		averrage=(firstMark+secondMark+thirdMark)/3;
	}


}

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