How to end a while Loop via user input

前端 未结 5 369
深忆病人
深忆病人 2021-01-22 18:42
package cst150zzhw4_worst;

import java.util.Scanner;

public class CST150zzHW4_worst {

    public static void main(String[] args) {
    //Initialize Variables
    doub         


        
5条回答
  •  离开以前
    2021-01-22 18:58

        boolean repeat = true;
    
       // Create a Scanner object for keyboard input.
         Scanner keyboard = new Scanner(System.in);
    
        while (repeat)
        {   
           -----------------------
           -------------------------
           System.out.println("Do you want to continue:");
           repeat = keyboard.nextBoolean();
        }
    

提交回复
热议问题