Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Class:
- public class HostCarry{
- public static void main(String []args){
- System.out.println("Hello World!");
- }
- }
- ---
- If statement:
- public class HostCarry{
- public static void main(String []args){
- int a = 10;
- if(a>=10)
- {
- System.out.println("a: " + a);
- }
- }
- }
- ---
- If, else statement:
- public class HostCarry{
- public static void main(String []args){
- int a = 10;
- if(a>=12)
- {
- System.out.println("a: " + a);
- }
- else
- {
- System.out.println("No Data");
- }
- }
- }
- ---
- else if statement:
- import java.util.*;
- public class HostCarry{
- public static void main(String []args){
- int age;
- System.out.println("Enter value of age: ");
- Scanner input = new Scanner(System.in);
- age = input.nextInt();
- if (age<=0)
- {
- System.out.println("You have not borned yet");
- }
- else if (age>0 && age<=12)
- {
- System.out.println("You are a child");
- }
- else if (age>12 && age<=19)
- {
- System.out.println("You are a teen ager");
- }
- else if (age>19 && age<=40)
- {
- System.out.println("You are young");
- }
- else
- {
- System.out.println("Wise your long life");
- }
- }
- }
Add Comment
Please, Sign In to add comment