0% found this document useful (0 votes)
55 views

Switch Case Digit

This Java code defines a method called "digit" that uses a switch statement to print out the name of a number (in Indonesian) corresponding to a digit entered by the user. The digit method recursively calls itself to allow multiple numbers to be entered and printed in a loop. The main method simply calls digit() to start the recursive loop.

Uploaded by

leni7setiani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

Switch Case Digit

This Java code defines a method called "digit" that uses a switch statement to print out the name of a number (in Indonesian) corresponding to a digit entered by the user. The digit method recursively calls itself to allow multiple numbers to be entered and printed in a loop. The main method simply calls digit() to start the recursive loop.

Uploaded by

leni7setiani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

import java.util.

Scanner;
public class switchcase_5 {
public static void digit(){
int a;
Scanner input = new Scanner (System.in);
System.out.print("Masukkan Karakter Digit anda = ");
a = input.nextInt();
switch (a) {
case 0: System.out.println("Nol");
digit();
break;
case 1: System.out.println("Satu");
digit();
break;
case 2: System.out.println("Dua");
digit();
break;
case 3: System.out.println("Tiga");
break;
case 4: System.out.println("Empat");
digit();
break;
case 5: System.out.println("Lima");
digit();
break;
case 6: System.out.println("Enam");
digit();
break;
case 7: System.out.println("Tujuh");
digit();
break;
case 8: System.out.println("Delapan");
digit();
break;
case 9: System.out.println("Sembilan");
digit();
break;
default: System.out.println("bukan karakter digit");
digit();
}
}
public static void main(String[] args) {
digit();
}

You might also like