Question
Write a program in to input and store all roll numbers, names and marks in 3 subjects of n number of students in five single dimensional arrays and display the remark based on average marks as given below:
Average marks = total marks/3
AVERAGE MARKS REMARK
85 – 100: EXCELLENT
75 – 84 :DISTINCTION
60 – 74 :FIRST CLASS
40 – 59 :PASS
Less than 40: POOR
Share code with your friends
Share on whatsapp
Share on facebook
Share on twitter
Share on telegram
Code
import java.util.Scanner;
public class program6
{
public static void main(String[] args)
{
int i=0;
double average=0;
Scanner sc = new Scanner(System.in);
System.out.print("Enter number of students: ");
int n = sc.nextInt();
int[] rollNos = new int[n];
String[] names = new String[n];
int[] subject1 = new int[n];
int[] subject2 = new int[n];
int[] subject3 = new int[n];
for (i = 0; i < n; i++)
{
System.out.println("Student " + (i + 1));
System.out.print("Enter roll number: ");
rollNos[i] = sc.nextInt();
System.out.print("Enter name: ");
sc.nextLine();
names[i] = sc.nextLine();
System.out.print("Enter marks in subject 1: ");
subject1[i] = sc.nextInt();
System.out.print("Enter marks in subject 2: ");
subject2[i] = sc.nextInt();
System.out.print("Enter marks in subject 3: ");
subject3[i] = sc.nextInt();
}
for(i = 0; i < n; i++)
{
System.out.println( "Name : " + names[i]);
System.out.println( "Roll Number : " + rollNos[i]);
average= (subject1[i] + subject2[i] + subject3[i]) / 3;
if (average >= 85 && average <= 100)
{
System.out.println("EXCELLENT");
}
else if(average >= 75 && average <= 84)
{
System.out.println("DISTINCTION");
}
else if (average >= 60 && average <= 74)
{
System.out.println("FIRST CLASS");
}
else if (average >= 40 && average <= 59)
{
System.out.println("PASS");
}
else if (average < 40)
{
System.out.println("POOR");
}
}
}
}
Coding Store
Sale

ISC QUESTION PAPERS WITH SOLUTION(PROGRAMMING ONLY)
Sale

ICSE QUESTION PAPER WITH SOLUTION(PROGRAMMING ONLY)
Sale

ISC QUESTION PAPERS WITH SOLUTION(PROGRAMMING ONLY)
Sale

ICSE QUESTION PAPER WITH SOLUTION(PROGRAMMING ONLY)
Sale

ISC QUESTION PAPERS WITH SOLUTION(PROGRAMMING ONLY)
Sale
