0% found this document useful (0 votes)
33 views2 pages

Import Java - Uti

This Java program takes marks for 6 subjects as input from the user, calculates the total and average marks, and uses the average to determine the grade (A, B, C or D) based on predefined thresholds. The program initializes an array of size 6 to store the marks for each subject, uses a for loop to take input from the user and store in the array, calculates total and average, and then uses if/else conditions to assign a letter grade based on the average.

Uploaded by

Getahun Mengesha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views2 pages

Import Java - Uti

This Java program takes marks for 6 subjects as input from the user, calculates the total and average marks, and uses the average to determine the grade (A, B, C or D) based on predefined thresholds. The program initializes an array of size 6 to store the marks for each subject, uses a for loop to take input from the user and store in the array, calculates total and average, and then uses if/else conditions to assign a letter grade based on the average.

Uploaded by

Getahun Mengesha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

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");

You might also like