0% found this document useful (0 votes)
4 views1 page

Import Java - Util.scanner

The Java program collects the names and marks of a specified number of students. It assigns grades based on the marks: 'A' for 90-100, 'B' for 80-89, 'C' for 70-79, and 'Fail' for below 70. Finally, it prints each student's name, grade, and marks.

Uploaded by

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

Import Java - Util.scanner

The Java program collects the names and marks of a specified number of students. It assigns grades based on the marks: 'A' for 90-100, 'B' for 80-89, 'C' for 70-79, and 'Fail' for below 70. Finally, it prints each student's name, grade, and marks.

Uploaded by

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

import java.util.

Scanner;
class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);

System.out.print("enter no of students-");
int n=sc.nextInt();
sc.nextLine();

String name[]=new String[n];


int marks[]=new int[n];
String[] grade = new String[n];

for(int i=0;i<n;i++){
System.out.print("Enter name of student-");
name[i]=sc.nextLine();

System.out.print("Enter marks of student: ");


marks[i] = sc.nextInt();
sc.nextLine();

if(marks[i]>=90&&marks[i]<=100){
grade[i]="A";
}
else if(marks[i]>=80){
grade[i]="B";
} else if(marks[i]>=70){
grade[i]="C";
}
else{
grade[i]="Fail";
}
}
System.out.println("You entered-");
for(int i=0;i<n;i++){
System.out.println("The name is- "+name[i]+" ,Grade is- "+grade[i]+" ,Marks
are- "+marks[i]);
}

sc.close();
}
}

You might also like