Assignment 3 PCP
Assignment 3 PCP
import java.util.Scanner;
public class Assignment3 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);// Creating an object named input for taking the inputs.
while(true) {// This while loop will keep running the program
System.out.println("Enter Students Name: ");// This will print the expression mentioned in "".
String StudentName=input.next();// Taking String input from the user.
System.out.println("Enter Grade 1:");// This will print the expression mentioned in "".
int Grade1=input.nextInt();// Taking integer input from the user.
System.out.println("Enter Grade 2:");// This will print the expression mentioned in "".
int Grade2=input.nextInt();// Taking integer input from the user.
if(Grade1<0 || Grade2<0){// If condition to validate that numbers are not less than 0.
System.out.println("Error: Grades cannot be Negative");// This will print the expression
mentioned in "".
}
else if(Grade1>=50 && Grade2>=50){// If condition to evaluate the student has passed if yes then
this loop will run.
System.out.println(StudentName+ " has passed the examination");// This will print the
name of student and expression mentioned in "".
}
else {// If student does not pass then this loop will run.
System.out.println(StudentName+ " has failed the examination");// This will print the name
of student and expression mentioned in "".
}
}
}
}