0% found this document useful (0 votes)
3 views4 pages

Java Programs for Year and Grade Check

Uploaded by

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

Java Programs for Year and Grade Check

Uploaded by

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

Program - Checking for Leap year using nested if

Source Code:
import [Link];
public class Leapyear
{
public static void main(String[] args)
{
int year
Scanner console = new Scanner([Link]);
[Link]("Enter a year : ");
year = [Link]();
if (year % 4 == 0)
{
if (year % 100 == 0)
{
if (year % 400 == 0)
{
[Link]("A leap year");
}
else
{
[Link]("Not a leap year");
}
}
else
{
[Link]("A leap year");
}
}
else
{
[Link]("Not a leap year");
}
}}

Output:
Program - Finding grade of students using if elseif ladder
Source code:
import [Link];
public class Grade {
public static void main(String[] args) {
Scanner scan = new Scanner([Link]);
[Link]("Enter percentage marks");
double percentage = [Link]();
if(percentage >= 90){
[Link]("Excellent: Grade A");
}else if(percentage < 90 && percentage >= 80){
[Link]("Very Good: Grade B");
}else if(percentage < 80 && percentage >= 70){
[Link]("Good: Grade C");
}else if(percentage < 70 && percentage >= 60){
[Link]("Satisfactory: Grade D");
}else if(percentage < 60 && percentage >= 50){
[Link]("Work Hard: Grade E");
}else if(percentage < 50 && percentage >= 40){
[Link]("Just Passed: Grade F");
}else {
[Link]("Failed!");
}
}
}
Output:

You might also like