How can I loop my program with a yes or no prompt?

+1 vote
asked Mar 17 by (130 points)
import java.util.Scanner;

public class Main

{

  public static void main (String[]args)

  {

    int itlogAmount;

    int gatasAmount;

    int harinaAmount;

      System.out.println ("Maayong adlaw kanimo!");

      System.out.println (" ");

      System.out.println ("Ga sugod na ang Pancake calculator...hulat lng");

      System.out.println (" ");

    Scanner userInput;

      System.out.println ("pila imong itlog?");

      System.out.println (" ");

      System.out.println ("Note:Ang minimum na bahin sa itlog kay isa");

      userInput = new Scanner (System.in);

      itlogAmount = userInput.nextInt ();

    if (itlogAmount <= 1)

      {

System.out.println ("kol kulang imo itlog, di ka ka himo og pancake");

      }

    else

        System.out.println ("oki ra kol");

    System.out.println (" ");

    System.out.println ("pila imong gatas?");

    System.out.println (" ");

    System.out.println ("Note:Ang minimum na bahin sa gatas kay 200ml");

    userInput = new Scanner (System.in);

    gatasAmount = userInput.nextInt ();

    if (gatasAmount <= 200)

      {

System.out.println ("kol kulang imo gatas, di ka ka himo og pancake");

      }

    else

      System.out.println ("oki ra kol");

    gatasAmount = gatasAmount / 200;

    System.out.println ("naa kay " + gatasAmount + " ka bahin sa gatas");

    System.out.println (" ");

    System.out.println ("pila imong harina?");

    System.out.println (" ");

    System.out.println ("note:Ang minimum na bahin sa harina kay 400g");

    userInput = new Scanner (System.in);

    harinaAmount = userInput.nextInt ();

    if (harinaAmount <= 400)

      {

System.out.

  println ("kol kulang imo harina, di ka ka himo og pancake");

      }

    else

      System.out.println ("oki ra kol");

    harinaAmount = harinaAmount / 400;

    System.out.println ("naa kay " + harinaAmount + " ka bahin sa harina");

    System.out.println (" ");

    int smallest;

    if (itlogAmount <= gatasAmount && gatasAmount <= harinaAmount)

      {

smallest = itlogAmount;

      }

    else if (gatasAmount <= harinaAmount && gatasAmount <= itlogAmount)

      {

smallest = gatasAmount;

      }

    else

      {

smallest = harinaAmount;

      }

    System.out.println (" ");

    System.out.println ("maka himo ka og " + smallest * 4 +

" ka bahin sa pancake");

    System.out.println ("kada bahin kay upat ka pancake");

    System.out.println (" ");

    System.out.println ("Kailangan nimo og " + smallest * 1 + " itlog");

    System.out.println ("Kailangan nimo og " + smallest * 400 +

" gramo sa harina");

    System.out.println ("Kailangan nimo og " + smallest * 200 +

" milliliter sa gatas");

    System.out.println (" ");

    System.out.println

      ("Salamat sa pag gamit. Pancake calculator shutting down...");

  }

}

1 Answer

0 votes
answered Mar 20 by (140 points)
Maybe try implementing a while loop. I am not sure how to make while loops in java since I use cpp. In cpp it looks something like this:

int main()

{

     string answer = "no";

     while (answer = "no")

      {

       cin>>answer;

       }

}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...