Computer Science, asked by tanduioscar01, 10 months ago

a java program that calculates students score in subjects

Answers

Answered by harsh05572
1

import java.util.Scanner;

public class JavaExample

{

public static void main(String args[])

{

/* This program assumes that the student has 6 subjects,

* thats why I have created the array of size 6. You can

* change this as per the requirement.

*/

int marks[] = new int[6];

int i;

float total=0, avg;

Scanner scanner = new Scanner(System.in);

for(i=0; i<6; i++) {

System.out.print("Enter Marks of Subject"+(i+1)+":");

marks[i] = scanner.nextInt();

total = total + marks[i];

}

scanner.close();

//Calculating average here

avg = total/6;

System.out.print("The student Grade is: ");

if(avg>=80)

{

System.out.print("A");

}

else if(avg>=60 && avg<80)

{

System.out.print("B");

}

else if(avg>=40 && avg<60)

{

System.out.print("C");

}

else

{

System.out.print("D");

}

}

}

follow me please please making efforts mate.....

Answered by sushiladevi4418
0

Answer:

A java program that calculates students score in subjects

Explanation:

/* Java Program Example - Calculate Grade of Student */

import java.util.Scanner;

public class JavaProgram

{

   public static void main(String args[])

   {

       int mark[] = new int[5];

       int i;

       float sum=0, avg;

       Scanner scan = new Scanner(System.in);  

       System.out.print("Enter Marks Obtained in 5 Subjects : ");

       for(i=0; i<5; i++)

       {

           mark[i] = scan.nextInt();

           sum = sum + mark[i];

       }

       avg = sum/5;  

       System.out.print("Your Grade is ");

       if(avg>80)

       {

           System.out.print("A");

       }

       else if(avg>60 && avg<=80)

       {

           System.out.print("B");

       }

       else if(avg>40 && avg<=60)

       {

           System.out.print("C");

       }

       else

       {

           System.out.print("D");

       }

   }

}

Ouput:

Enter marks obtained in 5 subject: 60

                                                             70

                                                             80

                                                             90

                                                             100

Your Grade is B

Similar questions