Java Basic Activities: Logical Operators w/ nested else if



=========================
Code: 
===========================
import java.util.Scanner;

public class Test32_Pereda_Logicalland {

public static void main(String [] args) {

Scanner input = new Scanner(System.in);

int age, num1;


System.out.print("Enter a number: ");
num1 = input.nextInt();

System.out.print("enter your age: ");
age = input.nextInt();

if (num1 <100 && age> 60) {
   System.out.println("Congratulation you win a lucky prize!");

}

else {
System.out.println("Sorry , did not win any prize!");

}

input.close();
}

}
=====================================


========================
Code: 
========================

import java.util.Scanner;

public class Test33_Pereda_Challege {

public static void main(String [] args) {

System.out.println("=================================================================");
System.out.println("| Name:Sonny Pereda                                             |");
System.out.println("| Subject Code: CC101                                           |");
System.out.println("| Subject Title: Programming Language                           |");
System.out.println("| Activity no.33                                                |");
System.out.println("| Instructor: Clinton Reducto                                   |");
System.out.println("=================================================================");

Scanner input = new Scanner(System.in);
int num1;

System.out.println("\n\nEnter your grade in CC101:");
num1 = input.nextInt();



if (num1<=100 && num1>=98 ) {
System.out.println("Grade Point Equivalent: 1.0 ");
System.out.println("Exellent");

}
else if (num1<=97 && num1>=95 ) {
System.out.println("Grade Point Equivalent: 1.25 ");
System.out.println("Very good");

}

else if (num1<=94 && num1 >=92 ) {
System.out.println("Grade Point Equivalent: 1.75 ");
System.out.println("Execent");

}

else if (num1<=91 && num1 >=89 ) {
System.out.println("Grade Point Equivalent: 2.0 ");
System.out.println("Very good");

}

else if (num1<=88 && num1 >=86 ) {
System.out.println("Grade Point Equivalent: 2.25 ");
System.out.println("Very good");

}

else if (num1<=85 && num1 >=83 ) {
System.out.println("Grade Point Equivalent: 2.5 ");
System.out.println("Fair");

}

else if (num1<=80 && num1 >=82 ) {
System.out.println("Grade Point Equivalent: 2.75 ");
System.out.println("Very good");

}

else if (num1<=79 && num1 >=77 ) {
System.out.println("Grade Point Equivalent: 3.0 ");
System.out.println("Passed");

}

else if (num1<=76 && num1 >=75 ) {
System.out.println("Grade Point Equivalent: 3.0 ");
System.out.println("Failed");

}
else {System.out.println("Your faile");



}

input.close();
}


}




Walang komento:

Mag-post ng isang Komento