Write a Java program that determines a student’s grade


if the average score >=90% =>Student grade = A

if the average score >= 70% and <90% =>Student grade = B

if the average score>=50% and <70% =>Student grade = C

if the average score<50% =>Student grade = F

Introduction

In this demo I have used NetBeans IDE 8.2 for debugging purpose. But you can use any java programming language compiler as per your availability..


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. import java.util.*;
  2. public class JavaExcercise
  3. {
  4. public static void main(String[] args)
  5. {
  6. showGrade();
  7. }
  8.  
  9. static void showGrade(){
  10.  
  11. float quiz_score, mid_score,final_score,avg;
  12. Scanner sc=new Scanner(System.in);
  13. System.out.print("Enter you quiz score:");
  14. quiz_score=sc.nextFloat();
  15. System.out.print("Enter your Mid-term score:");
  16. mid_score=sc.nextFloat();
  17. System.out.print("Enter your Final score:");
  18. final_score=sc.nextFloat();
  19. avg=(quiz_score+mid_score+final_score)/3;
  20.  
  21. if(avg>=90) System.out.println("Your grade A.");
  22. else if((avg>=70) && (avg<90)) System.out.println("Your grade B.");
  23. else if((avg>=50) && (avg<70)) System.out.println("Your grade C.");
  24. else if(avg<50) System.out.println("Your grade F.");
  25. else System.out.println("Invalid");
  26.  
  27.  
  28. }
  29.  
  30. }

Result

java techstudy.org

     





Related Topics




Popular Posts