khalequzzaman17

Java Program - Alamgir Sir

Sep 21st, 2021 (edited)
893
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.51 KB | None | 0 0
  1. Class:
  2.  
  3. public class HostCarry{
  4.  
  5.      public static void main(String []args){
  6.         System.out.println("Hello World!");
  7.      }
  8. }
  9.  
  10. ---
  11.  
  12. If statement:
  13.  
  14. public class HostCarry{
  15.  
  16.      public static void main(String []args){
  17.          int a = 10;
  18.          if(a>=10)
  19.          {
  20.              System.out.println("a: " + a);
  21.          }
  22.        
  23.      }
  24. }
  25.  
  26. ---
  27.  
  28. If, else statement:
  29.  
  30. public class HostCarry{
  31.  
  32.      public static void main(String []args){
  33.          int a = 10;
  34.          if(a>=12)
  35.          {
  36.              System.out.println("a: " + a);
  37.          }
  38.          else
  39.          {
  40.              System.out.println("No Data");
  41.          }
  42.        
  43.      }
  44. }
  45.  
  46. ---
  47.  
  48. else if statement:
  49.  
  50. import java.util.*;
  51. public class HostCarry{
  52.  
  53.      public static void main(String []args){
  54.          int age;
  55.          System.out.println("Enter value of age: ");
  56.          Scanner input = new Scanner(System.in);
  57.          age = input.nextInt();
  58.          if (age<=0)
  59.          {
  60.              System.out.println("You have not borned yet");
  61.          }
  62.          else if (age>0 && age<=12)
  63.          {
  64.              System.out.println("You are a child");
  65.          }
  66.          else if (age>12 && age<=19)
  67.          {
  68.              System.out.println("You are a teen ager");
  69.          }
  70.          else if (age>19 && age<=40)
  71.          {
  72.              System.out.println("You are young");
  73.          }
  74.          else
  75.          {
  76.              System.out.println("Wise your long life");
  77.          }
  78.                  
  79.      }
  80. }
Add Comment
Please, Sign In to add comment