
1) Write a Java program that reads the details of student and do the mark assessments.
(i) Input the name of the student and student id from the user. (Use String variable to hold the student name and long variable to hold the student id)
(ii) The number of subjects is 3. Use an array to store the marks of the three subjects. (Use any of the Looping statements to read the input of marks from the user three times)
(iii) The assessment is possible only if the student passes in all the 3 subjects. (Use any of the Selection statements to check whether the student has obtained more than 40 marks in all the three subjects)
(iv) Find the average of all the three subject marks.
(v) Follow the table for grading:
Average of Marks Grade
< 40 Fail
= 40 and < 60 (C)
= 60 and < 80 (B)
= 80 (A)
(vi) Output the Student name, Student id, subject marks, average mark and the grade obtained.

Java Student marks Assesment
In the given code, the user is allowed to enter name and id of the student. The user is then allowed to enter the marks of three subjects. Accordingly, average of marks is calculated and based on the average, grade is given to the student.
import java.util.*;
class MarksAssesment
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.print("Enter ID: ");
long id=input.nextLong();
System.out.print("Enter Name: ");
String name=input.next();
System.out.println("Enter Marks of three subjects: ");
int marks[]=new int[3];
int sum=0;
for(int i=0;i<marks.length;i++){
marks[i]=input.nextInt();
sum+=marks[i];
}
if(marks[0]>40&&marks[1]>40&&marks[2]>40){
System.out.println("Assesment is possible");
}
int average=sum/(marks.length);
String grade="";
System.out.println("Average of marks: "+average);
if(average<40){
grade="Fail!";
}
else if((average>=40) && (average<60)){
grade="C!";
}
else if((average>=60) && (average<80)){
grade="B!";
}
else if((average>=80) && (average<=100)){
grade="A!";
}
System.out.println("Student Name: "+name);
System.out.println("Student ID: "+id);
System.out.println("Student Marks");
for(int i=0;i<marks.length;i++){
System.out.println(marks[i]);
}
System.out.println("Average Marks: "+average);
System.out.println("Grade: "+grade);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.