repl.it
@Hariz_Hazril/

­čŹÁContoh - do while + if else

Java

No description

fork
loading
Files
  • Main.java
  • Main.class
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.util.Scanner;
public class Main {
   public static void main(String[] args) {
   Scanner scanner = new Scanner(System.in);
   String input;
   String g = "";
   do {
      System.out.println("Masukkan markah anda:");
      int markah = scanner.nextInt();
      if (markah >= 90) {
        g = "A+";
        } else if (markah >=80) {
        g = "A";
        } else if (markah >=70) {
        g = "A-";
        } else if (markah >=65) {
        g = "B+";
        } else if (markah >=65) {
        g = "B";
        } else if (markah >=60) {
        g = "C+";
        } else if (markah >=50) {
        g = "C";
        } else if (markah >=45) {
        g = "D";
        } else if (markah >=40) {
        g = "E";
        } else if (markah >=0) {
        g = "G";
      }
     System.out.println("Markah anda "+markah+" dan Gred ialah " + g);
     System.out.println("Ulang?");
     input = scanner.next();
  } while(input.equals("Ya")||input.equals("ya")|| input.equals("YA"));
  }
}