Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given int std1, std2, std3, std4, std5, avegrade;// avegrade is the average of t

ID: 3733484 • Letter: G

Question

Given

                  int std1, std2, std3, std4, std5, avegrade;// avegrade is the average of the 5 grades

                  std1 = 87;

                  std2 = 90;

                  std3 = 67;

                  std4 = 72;

                  std5 = 78; // as grades of five students

                  avegrade = 0;

      Write a program to perform the following tasks.

       I. declare and initialize std1, std2, std3, std4, std5, and avegrade as above.

       II. compute the average grade of the five students and assign it to avegrade, and then display the

            average grade on the screen.

       III. Using if – else statement:

             If the avegrade is >= 80, display message “A level” on the screen.

             If the avegrade is >= 60 and < 80, display message “B level” on the screen.

             If the avegrade is < 60, display message “C level“ on the screen.

Explanation / Answer

AverageLevel.java

public class AverageLevel {

public static void main(String[] args) {

int std1, std2, std3, std4, std5, avegrade;// avegrade is the average of the 5 grades

std1 = 87;

std2 = 90;

std3 = 67;

std4 = 72;

std5 = 78; // as grades of five students

avegrade = 0;

avegrade = (std1+std2+std3+std4+std5)/5;

System.out.println("Average: "+avegrade);

if(avegrade>=80) {

System.out.println("A Level");

} else if(avegrade>=60 && avegrade<80){

System.out.println("B Level");

}else{

System.out.println("C Level");

}

}

}

Output:

Average: 78
B Level

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote