HarrJ

day 9 group samples

Jun 30th, 2023 (edited)
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. public class PositiveNegativeExample {
  2. public static void main(String[] args) {
  3. int number=-13;
  4. if(number>0){
  5. System.out.println("POSITIVE");
  6. }else if(number<0){
  7. System.out.println("NEGATIVE");
  8. }else{
  9. System.out.println("ZERO");
  10. }
  11. }
  12. }
  13. //------DIFFERENT FILE------------------------------------------------
  14. public class Group1Sample2 {
  15. public static void main(String[] args) {
  16. int i = 20;
  17. if(i == 10)
  18. System.out.println("i is 10");
  19. else if(i == 15)
  20. System.out.println("i is 15");
  21. else if(i == 20)
  22. System.out.println("i is 20");
  23. else
  24. System.out.println("i is not present");
  25. }
  26. }
  27.  
  28. //------DIFFERENT FILE------------------------------------------------
  29. class GFG
  30. {
  31. public static void main(String args[])
  32. {
  33. int a=10;
  34. int b=20;
  35.  
  36. if(a==10){
  37. if(b==20){
  38. System.out.println("GeeksforGeeks");
  39. }
  40. }
  41. }
  42. }
  43.  
  44. //------DIFFERENT FILE------------------------------------------------
  45. public class Group1Sample4 {
  46. public static void main(String[] args) {
  47. int i = 10;
  48. if (i < 15) {
  49. System.out.println("i is smaller than 15");
  50. if (i < 12) {
  51. System.out.println("i is smaller than 12 too");
  52. }
  53. }
  54. else {
  55. System.out.println("i is greater than 15");
  56. }
  57. }
  58. }
  59.  
  60. // nalabas yung out para sa tama username + password, maling username
  61. // paano palalabasin yung error pag wrong password lang
  62. public static void main(String[] args) {
  63. Scanner uInput = new Scanner(System.in);
  64. String uName, pWord;
  65.  
  66. System.out.print("Enter username: ");
  67. uName = uInput.nextLine();
  68.  
  69. System.out.print("Enter password: ");
  70. pWord = uInput.nextLine();
  71.  
  72. // for String use .equals instead of ==
  73. if (uName.equals("MNG")) {
  74. if (pWord.equals("2023Java")) {
  75. System.out.println("Welcome to your account");
  76. }
  77. } else {
  78. System.out.println("Invalid Username or Password");
  79. }
  80. }
  81.  
  82. //------Show if day number is weekdays or weekends----------------
  83. public static void main(String[] args) {
  84. int day = 2;
  85. switch (day) {
  86. case 1:
  87. System.out.println("Sunday");
  88. break;
  89. case 2:
  90. System.out.println("Monday");
  91. break;
  92. case 3:
  93. System.out.println("Tuesday");
  94. break;
  95. case 4:
  96. System.out.println("Wednesday");
  97. break;
  98. case 5:
  99. System.out.println("Thursday");
  100. break;
  101. case 6:
  102. System.out.println("Friday");
  103. break;
  104. case 7:
  105. System.out.println("Saturday");
  106. break;
  107. default:
  108. System.out.println("number out of bounds");
  109. }
  110. }
  111.  
Advertisement
Add Comment
Please, Sign In to add comment