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

Question #174218

(i) 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


(ii) 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.


(iii) 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-03-23T16:20:43-0400
import java.util.Scanner;

class Grade_record{

private String courseName;

// constructor

public Grade_record(String name){

courseName = name;

}

// setters

public void setCourseName(String name){

courseName = name;

}

//getters

public String getCourseName(){

return courseName;

}

// determine class average based on 10 user-entered grades

public void determineClassAverage(){

Scanner sc = new Scanner(System.in);

int total=0, gradeCounter=0, grade, above_eighty=0, below_fifty=0;

double average;

System.out.printf("Enter grade 1 or -1 to quit: ");

grade = sc.nextInt();

while(grade != -1)

{

if(grade >= 80) above_eighty++;

if(grade <= 50) below_fifty++;

total += grade;

gradeCounter++;

System.out.printf("Enter grade %d or -1 to quit: ", gradeCounter+1);

grade = sc.nextInt();

}

if(gradeCounter != 0){

average = (double)total / gradeCounter;

//display grades average

System.out.printf("\nTotal of the %d grades: %d\n", gradeCounter, total);

System.out.printf("Class average: %.2f\n", average);

System.out.printf("\nNumber of students below or eual to 50: %d", below_fifty);

System.out.printf("\nNumber of students above or eual to 80: %d", above_eighty);

}

}

}

public class My_class{

public static void main(String[] args){ Grade_record myGradeBook = new Grade_record("CS101 Introduction to Java Programming");

myGradeBook.determineClassAverage();

}

}

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