Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Method {
- public static void main(String[] args) {
- boolean play = true;
- Scanner getInput = new Scanner(System.in);
- while(play) {
- int textMany = 0;
- String textToPrint = "";
- ask();
- print(textToPrint, textMany);
- System.out.print("Apakah anda ingin lanjut? (Y/N) : ");
- String cont = getInput.nextLine();
- if (cont=="N" || cont=="n") {
- play = false;
- }
- }
- getInput.close();
- }
- public static void ask() {
- Scanner getInput = new Scanner(System.in);
- System.out.print("Masukan string yang ingin di tampilkan : ");
- textToPrint = getInput.nextLine();
- System.out.print("Berapa kali string ingin di tampilkan? : ");
- textMany = getInput.nextLine();
- getInput.close();
- }
- public static void print(String text, int n) {
- for(int i=1; i<=n ; i++) {
- System.out.println(text);
- }
- }
- }
Add Comment
Please, Sign In to add comment