Southern New Hampshire University How to Code Through Loops Project

In Module Five, you have studied how to code for iteration through the use of loops. In Stepping Stone Lab Four, you will develop a simple program with a loop structure. Then, you will reflect on how loops may be used to help structure the program you have worked with throughout the stepping stones.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Go to the Start Here page and download the Stepping Stone code .zip for the starter code for this assignment.

To complete this assignment, review the following documents:

  • Stepping Stone Lab Four Guidelines
  • Stepping Stone Labs Two Through Six Rubric
  • package SteppingStones;
    /*
    * To change this license header, choose License Headers in Project Properties.
    * To change this template file, choose Tools | Templates
    * and open the template in the editor.
    */
    import java.util.Scanner;
    import java.util.ArrayList;
    public class SteppingStone4_Loops {
    public static void main(String[] args) {
    Scanner scnr = new Scanner(System.in);
    String recipeName = “”;
    ArrayList ingredientList = new ArrayList();
    String newIngredient = “”;
    boolean addMoreIngredients = true;
    System.out.println(“Please enter the recipe name: “);
    recipeName = scnr.nextLine();
    do {
    System.out.println(“Would you like to enter an ingredient: (y or n)”);
    String reply = scnr.next().toLowerCase();
    /**
    * Add your code here (branches work well!). The code should check the
    * reply:
    * “y” –> prompt for the ingredient and add it to the ingredient list;
    * “n” –> break out of the loop;
    *
    (Hint: what is the ‘while’ condition? What could you change to
    *
    stop the loop from starting over?)
    * anything else –> prompt for a “y” or “n”
    *
    */
    } while (addMoreIngredients);
    for (int i = 0; i < ingredientList.size(); i++) { /** * Get the item i from the ingredient list * and assigning it to the String ingredient * */ String ingredient = ???; System.out.println(ingredient); } } }

    Save Time On Research and Writing
    Hire a Pro to Write You a 100% Plagiarism-Free Paper.
    Get My Paper
    Still stressed from student homework?
    Get quality assistance from academic writers!

    Order your essay today and save 25% with the discount code LAVENDER