
1.convert the following Pseudo code to java if/else structure
if student?s grade is greater than or equal to 90 Print ?A?
else
if student?s grade is greater than or equal to 80
Print ?B?
else
if student?s grade is greater than or equal to 70
Print ?C?
else
if student?s grade is greater than or equal to 60
Print ?D?
else
Print ?F?

Here is a code that accepts the number of students and their marks and display their respective grades.
import java.util.*;
public class StudentMarks{
double totalMarks;
String grade;
public void setTotalMarks(double totalMarks){
this.totalMarks=totalMarks;
}
public double getTotalMarks(){
return totalMarks;
}
public void setGrade(String grade){
this.grade=grade;
}
public String getGrade(){
return grade;
}
public static void main(String[]args){
Scanner input=new Scanner(System.in);
System.out.print("Enter number of students: ");
int num=input.nextInt();
StudentMarks data[]=new StudentMarks[num];
for (int i=0; i<data.length; i++) {
System.out.println("Enter marks");
double marks=input.nextDouble();
data[i] = new StudentMarks();
data[i].setTotalMarks(marks);
if(marks>=90&&marks<=100){
data[i].setGrade("A");
}
else if(marks>=80&&marks<=89){
data[i].setGrade("B");
}
else if(marks>=70&&marks<=79){
data[i].setGrade("C");
}
else if(marks>=60&&marks<=69){
data[i].setGrade("D");
}
else{
data[i].setGrade("F");
}
}
for(int i=0;i<num;i++){
StudentMarks show = data[i];
System.out.println(show.getTotalMarks()+":"+show.getGrade());
}
}
}
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.