import java.util.*; // importing package utilpublic class Prime{ public static void main (String args<>) { int num,count=0; Scanner sdeserve to = brand-new Scanner(System.in); //scanner for input System.out.print("Get in any number : "); num = scan.nextInt(); for(int i=2; i
You are watching: Do you wish to continue yes or no
This is a pretty conventional way I learnt when I started coding.
Use a do-while loop prefer this:
do{ System.out.print("Enter any number : "); num = scan.nextInt(); for(int i=2; i If the user enter"s anything else, the loop will certainly break. :)

String awnser="";do{ int num,count=0; Scanner sdeserve to = new Scanner(System.in); //scanner for input System.out.print("Enter any type of number : "); num = sdeserve to.nextInt(); for(int i=2; i

go with switch case
System.out.print("DO you to continue Y/N: "); String answer = shave the right to.nextLine(); switch (answer) situation "Y" case "y": //WRITE YOUR CODE HERE break; situation "N" instance "n"://leave from program; break; default : System.out.println("invalid choice") ; break;


You Can try this ..
import java.util.Scanner;// importing package utilpublic course Prime{ static Scanner sdeserve to = brand-new Scanner(System.in); static String userInput = null; public static void main(String args<>) checkPrime(); while (true) System.out.print("Are You Want to Continue (Y/N) ?"); userInput = shave the right to.next(); if (userInput.equalsIgnoreCase("Y")) checkPrime(); else if (userInput.equalsIgnoreCase("N")) System.out.print("Thank you !!"); break; else System.out.print("Try Aget With (Y/N) just !"); public static void checkPrime() { int num, count = 0; System.out.print("Enter any kind of number : "); num = scan.nextInt(); for (int i = 2; i
See more: My Walk My Talk The Way I Dress It'S Not My Fault So Please
import java.io.InputStream;import java.util.Scanner;public course example1 static int value;static int quantity;static int complete = 0;static int total_offered = 0;static int total_cashier = 0;static float expensier = 0;int aget = 1;static String answer;public static void main(String<> args) while (true) System.out.print("Are You Want to Continue (Y/N) ?
");Scanner ans = brand-new Scanner(System.in);answer =ans.nextLine();if (answer.equalsIgnoreCase("Y")) Scanner input = brand-new Scanner(System.in);System.out.println("Input Price:
");value = input.nextInt();Scanner input2 = brand-new Scanner(System.in);System.out.println("Input Quantity:
");quantity = input2.nextInt();complete += worth * quantity;total_cashier += total;if (worth > expensier) expensier = value;total_marketed += quantity; else if (answer.equalsIgnoreCase("N")) System.out.print("Thank you !!");break; else System.out.print("Try Aget With (Y/N) just !");System.out.println("Total to pay :" + total);System.out.println("Value of the expensiest product: " + expensier);System.out.println("Amount of commodities sold: " + total_sold);System.out.println("Amount of cash in cashier: " + total_cashier);