JAVA PROGRAMS
JAVA PROGRAMS
YEAR PROBLEM_BERNABE
NO
NO
YES
NO
YES
NO
YES
GRADE Problem_BERNABE
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
NO
YES
PARRKINGFEEProblem_BERNABE
ELECTRICBILLProblem_BERNABE
YES
YES
NO
NO
YES
YES
NO
NO
YES
YES
GRADEProblemUSING SWITCH_BERNABE
CommodityCodeProblemUsingSwitch_BERNABE
YES
NO
YES
YES
NO
YES
NO
YES
NO
YES
NO
NO YES
YES
NO
NO
YES YES
TRAPEZOIDPROBLEM_BERNABE
YES
NO
YES
NO YES
YES
JAVA PROGRAMS
import
java.util
.Scanne
r; public
class
if_case1
{
public static void main(String[]args){
Scanner enter = new
Scanner (System.in);
int x,y,z;
System.out.print("Enter x: ");
//prompt to enter a value of x x
= enter.nextInt();
System.out.print("Enter y: ");
//prompt to enter a value of y y
= enter.nextInt();
System.out.print("Enter z: ");
//prompt to enter a value of z z =
enter.nextInt();
if (x>y && y>z){ //1st
condition
System.out.print("The
highest number is: "+x
+"\n The median number is: "+y //1st output
+"\n The lowest numbes is: "+z
+"\n Ascending order "+z+" "+y+" "+x+ "\n ");
}
}
import java.util.Scanner;
public class if_case2 {
public static void main(String[]args){
Scanner enter = new Scanner
(System.in);//prompt to enter year
System.out.print("Enter a year: ");
int year =
enter.nextInt();
if(year%100
==0){//1st
condition
System.out.print("It is a century year. ");//1st output
}
else if(year%4==0 ){//2nd
condition
System.out.print("It is a
leap year. ");//2nd output
}
else //last condition
System.out.print("It is a ordinary year. ");//last output
}
}
import
java.util
.Scanne
r; public
class
if_case3
{
public static void main(String[]args){
Scanner enter = new Scanner
(System.in); System.out.print("Enter
a Grade: ");//prompt to enter a
Grade int Grade = enter.nextInt();