Prompt: In this stepping stone lab assignment, you will build a Recipe class, getting user input to collect the recipe name and serving size, using the ingredient entry code from Stepping Stone Lab Four to add ingredients to the recipe, and calculating the calories per serving. Additionally, you will build your first custom method to print the recipe to the screen. Specifically, you will need to create the following: The instance variables for the class (recipeName, serving size, and recipeIngredients) The methods (the accessors/mutators, the constructors, and the extra print details method) for the class A custom method to print the recipe out to the console *To test the functionality of your finished code, use the SteppingStone5_RecipeTest.java file *Replace the public static void main(String[] args) with public SteppingStone5_Recipe createNewRecipe()
1. Modify this code to develop a Recipe class: A. Change the void main method createNewRecipe() that returns a Recipe 2. Change the ArrayList type to an Ingredient object. When a user adds an ingredient to the recipe, instead of adding just the ingredient name, you will add the actual ingredient including name, amount, measurement type, and calories. For the Milestone Two submission, the recipeIngredients ArrayList can remain as a string type. 3. Adapt the printRecipe() method to print the amount and measurement type as well as the ingredient name. 4. Create a custom method in the Recipe class. Choose one of the following options: A. Print out a recipe with amounts adjusted for a different number of servings. B. Create an additional list or ArrayList that allows users to insert step-by-step recipe instructions. C. Convert ingredient amounts from English to metric (or vice versa). D. Calculate select nutritional information. E. Calculate recipe cost.
What will be the code? And can you explain step by step on how to enter it.
package SteppingStones;
//Denisse.Carbo
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
public class SteppingStone5_Recipe {
private String recipeName;
private int servings;
private List<String> recipeIngredients;
private double totalRecipeCalories;
public String getRecipeName() {
return recipeName;
}
public void setRecipeName (string recipeName){
this.recipeName = recipeName;
}
public int getServings() {
return servings;
}
public void setServings(int servings) {
this.servings = servings;
}
public List<String> getRecipeIngredients() {
return recipeIngredients;
}
public void setRecipeIngredients() {
this.recipeIngredients = recipeIngredients;
}
public double getTotalRecipeCalories() {
return totalRecipeCalories;
}
public void setTotalRecipeCalories(double totalRecipeCalories)
{
this.totalRecipeCalories = totalRecipeCalories;
}
public SteppingStone5_Recipe() {
this.recipeName = "";
this.servings = 0;
this.recipeIngredients = new ArrayList<String> ();
this.totalRecipeCalories = 0;
}
public SteppingStone5_Recipe(String recipeName, int servings,
ArrayList<String> recipeIngredients, double
totalRecipeCalories)
{
this.recipeName = recipeName;
this.servings = servings;
this.recipeIngredients = recipeIngredients;
this.totalRecipeCalories = totalRecipeCalories;
}
public void printRecipe() {
int singleServingCalories = 0;
singleServingCalories = (int)
(this.totalRecipeCalories/this.servings);
System.out.println("Recipes: " + this.recipeName);
System.out.println("Serves: " + this.servings);
System.out.println("Ingredients: ");
for(String ingredients: recipeIngredients){
System.out.println(ingredients);
System.out.println("Each sercing has: " + singleServingCalories +
"Calories.");
}
}
public static void main(string[]args ) {
double totalRecipeCalories = 0.0;
ArrayList <String> recipeIngredients = new ArrayList();
boolean addMoreIngredients = true;
Scanner scnr = new Scanner(System.in);
System.out.println("Please enter the recipe name: ");
String recipeName = scnr.nextLine();
System.out.println("Please enter the number of servings: ");
//correct data type & Scanner assignment method for servings
variable
int servings = 0;
do {
System.out.println("Please enter the ingredient name
or type end if you are finished entering ingredients: ");
String ingredientName = scnr.next();
if (ingredientName.toLowerCase().equals("end")) {
addMoreIngredients = false;
} else {
/**
* Add the ingredient name to recipeIngredients
*
*/
System.out.println("Please enter the ingredient amount: ");
float ingredientAmount = scnr.nextFloat();
System.out.println("Please enter the ingredient Calories: ");
int ingredientCalories = scnr.nextInt();
/**
* Add the total Calories from this ingredient
* (ingredientCalories * ingredientAmount)
* to the totalRecipeCalories
*
*/
}
} while (!reply.equals("n") ;
SteppingStone5_Recipe recipe1 = new
SteppingStone5_Recipe(recipeName,
servings, recipeIngredients, totalRecipeCalories);
recipe1.printRecipe();
}
private static class string {
public string() {
}
}
}
/**
* 1. Modify this code to develop a Recipe class:
* a. change the void main method createNewRecipe() that returns a
Recipe
*
* 2. FOR FINAL SUBMISSION ONLY:Change the ArrayList type to
an
* Ingredient object. When a user adds an ingredient to the
recipe,
* instead of adding just the ingredient name, you will be adding
the
* actual ingredient including name, amount, measurement type,
calories.
* For the Milestone Two submission, the recipeIngredients ArrayList
can
* remain as a String type.
*
* 3. Adapt the printRecipe() method to print the amount and
measurement
* type as well as the ingredient name.
*
* 4. Create a custom method in the Recipe class.
* Choose one of the following options:
*
* a. print out a recipe with amounts adjusted for a different
* number of servings
*
* b. create an additional list or ArrayList that allow users
to
* insert step-by-step recipe instructions
*
* c. conversion of ingredient amounts from
* English to metric (or vice versa)
*
* d. calculate select nutritional information
*
* e. calculate recipe cost
Done. I have used Recipe class only. Dont udnerstand the exact purpose of Loop class. You can ignore it. Please have a look and in case of doubt please leave a comment. I have not removed your comments so that it is easy for you to understand the code. After the code is clear to you , please remove your comments.
/////////////////////////////////////Recipe.java/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
import java.util.ArrayList;
import java.util.Scanner;
public class Recipe {
private String recipeName;
private int serving;
private ArrayList<String> recipeIngredients;
private double totalRecipeCalories;
/**
* Add three variables:
*
* 1. a variable 'servings' to store how many people the recipe will feed;
*
* 2. an ArrayList variable 'recipeIngredients' to store the text for the names
* (recipeName) each recipe ingredient added
*
* 3. a variable totalRecipeCalories
*
*/
public Recipe() {
this.recipeName = "";
this.serving = 0;// <--- assignment value with appropriate data type
this.recipeIngredients = new ArrayList<String>(); // <-- assignment value for empty ArrayList
this.totalRecipeCalories = 0;
}
/**
* Add mutators and accessors for the class variable. Following are the Getters
* and Setters for all the class Variables
*/
public String getRecipeName() {
return recipeName;
}
public void setRecipeName(String recipeName) {
this.recipeName = recipeName;
}
public int getServing() {
return serving;
}
public void setServing(int serving) {
this.serving = serving;
}
public ArrayList<String> getRecipeIngredients() {
return recipeIngredients;
}
public void setRecipeIngredients(ArrayList<String> recipeIngredients) {
this.recipeIngredients = recipeIngredients;
}
public double getTotalRecipeCalories() {
return totalRecipeCalories;
}
public void setTotalRecipeCalories(double totalRecipeCalories) {
this.totalRecipeCalories = totalRecipeCalories;
}
public Recipe(String recipeName, int servings, ArrayList<String> recipeIngredients, double totalRecipeCalories)
// <-- use appropriate data type for the ArrayList and the servings arguments
{
this.recipeName = recipeName;
this.serving = servings;
this.recipeIngredients = recipeIngredients;
this.totalRecipeCalories = totalRecipeCalories;
}
public void printRecipe() {
/**
* Declare an int variable singleServingCalories. Assign singleServingCalories
* to the totalRecipeCalories divided by the servings
*
*/
int singleServingCalories = (int) totalRecipeCalories / serving;
System.out.println("Recipe:" + recipeName + " Serves: " + serving + " Ingredients: ");
for (int i = 0; i < recipeIngredients.size(); i++) {
System.out.print(recipeIngredients.get(i) + " ");
}
System.out.print(".Each serving has " + singleServingCalories + " calories");
/**
* Print the following recipe information: Recipe: <<recipeName>> Serves:
* <<servings>> Ingredients: <<Ingredient1>> <<Ingredient2>> ... <<Last
* Ingredient>>
*
* Each serving has <<singleServingCalories>> Calories.
*
* HINT --> Use a for loop to iterate through the ingredients
*/
}
public static void main(String[] args) {
double totalRecipeCalories = 200;
ArrayList<String> recipeIngredients = new ArrayList<String>();
boolean addMoreIngredients = true;
String reply = "";
Scanner scnr = new Scanner(System.in);
System.out.println("Please enter the recipe name: ");
String recipeName = scnr.nextLine();
System.out.println("Please enter the number of servings: ");
// correct data type & Scanner assignment method for servings variable
int servings = scnr.nextInt();
scnr.nextLine();
do {
System.out
.println("Please enter the ingredient name or type end if you are finished entering ingredients: ");
String ingredientName = scnr.nextLine();
if (ingredientName.toLowerCase().equals("end")) {
addMoreIngredients = false;
} else {
/**
* Add the ingredient name to recipeIngredients
*
*/
recipeIngredients.add(ingredientName);
System.out.println("Please enter the ingredient amount: ");
float ingredientAmount = scnr.nextFloat();
System.out.println("Please enter the ingredient Calories: ");
int ingredientCalories = scnr.nextInt();
scnr.nextLine();
/**
* Add the total Calories from this ingredient (ingredientCalories *
* ingredientAmount) to the totalRecipeCalories
*
*/
totalRecipeCalories = ingredientCalories * ingredientAmount;
System.out.println("Do you want to continue. Y/N");
reply = scnr.nextLine();
}
} while (!reply.equals("n"));
scnr.close();
Recipe recipe1 = new Recipe(recipeName, servings, recipeIngredients, totalRecipeCalories);
recipe1.printRecipe();
}
}

Prompt: In this stepping stone lab assignment, you will build a Recipe class, getting user input...
Can someone help me with my code.. I cant get an output. It says I do not have a main method. HELP PLEASE. The instruction are in bold on the bottom of the code. package SteppingStones; //Denisse.Carbo import java.util.Scanner; import java.util.ArrayList; import java.util.List; public class SteppingStone5_Recipe { private String recipeName; private int servings; private List<String> recipeIngredients; private double totalRecipeCalories; public String getRecipeName() { return recipeName; } public void setRecipeName (string recipeName){ this.recipeName = recipeName; } public int getServings() { return...
How to build Java test class? I am supposed to create both a recipe class, and then a class tester to test the recipe class. Below is what I have for the recipe class, but I have no idea what/or how I am supposed to go about creating the test class. Am I supposed to somehow call the recipe class within the test class? if so, how? Thanks in advance! This is my recipe class: package steppingstone5_recipe; /** * *...
I'm getting a few errors still under RecipeBox. Would you be able to see what's wrong? Thanks ------------ package recipecollection; import java.util.ArrayList; public class SteppingStone5_RecipeTest { public static void main(String[] args) { ArrayList<String> recipeIngredients = new ArrayList<>(); recipeIngredients.add("Peanut butter"); recipeIngredients.add("Jelly"); recipeIngredients.add("Bread"); SteppingStone5_Recipe recipe1 = new SteppingStone5_Recipe("Peanut butter & jelly sandwich", 2, recipeIngredients, 300, 10.0); System.out.println("RECIPE 1"); recipe1.printRecipe(); System.out.println(); recipe1.setRecipeName("Turkey sandwich"); recipe1.setServings(5); recipe1.setTotalRecipeCalories(500); System.out.println(); System.out.println("RECIPE 1 (Modified)"); recipe1.printRecipe(); System.out.println(); System.out.println("RECIPE 2"); SteppingStone5_Recipe recipe2 = SteppingStone5_Recipe.createNewRecipe(); recipe2.printRecipe(); } } ///////////////// package recipecollection;...
I would like someone to check my code and help with my for loop to print the recipe. It is incorrect. package SteppingStones; import java.util.Scanner; //Scanner class// import java.util.ArrayList; //ArrayList// import ingredients.Ingredient; /**Gets from package ingredients and class Ingredient * * @author kimbe */ public class SteppingStone5_Recipe { //Instance Variables// private ArrayList recipeIngredients; private String recipeName; private int servings; private double totalRecipeCalories; //Setter and Getters// public ArrayList getrecipeIngredients() { return recipeIngredients; }...
Hi. Could you help me with the code below? I need to validate the code below, using expressions that can carry out the actions or that make appropriate changes to the program’s state, using conditional and iterative control structures that repeat actions as needed. The unit measurement is missing from the final output and I need it to offer options to lbs, oz, grams, tbsp, tsp, qt, pt, and gal. & fl. oz. Can this be added? The final output...
I cannot submit my entire project due to the word count limit. I think my project looks ok, but my recipe box class and recipe test class is running errors and it may have something to do with the menu portion of the recipe box. Please take a look: "You will create a program that will help you manage a collection of recipes. You will implement three classes: one for the main recipe items, one for the ingredients that are...
1. Write a class that represents a Recipe as shown in the UML diagram below. Recipe -name: string -cookTime: int -prepTime: int - ingredients: ArrayList<String> +Recipe(String name, int cTime, int pTime, String... ingredients) +Recipe(String name, int cTime, int pTime) +getNumberOfIngredients(): int +addIngredient(String ingredient): void +getName(): String +getTotalRecipeTime(): int +get Ingredient(int index): String +remove Ingredient(String ingredient): String
*Please Add Inline Comments Directed toward software engineers about design decisions to facilitate the programs ongoing maintenance* import java.util.ArrayList; import java.util.Scanner; /** * * @author Eli Mishkit */ public class SteppingStone6_RecipeBox { /** * Declare instance variables: * a private ArrayList of the type SteppingStone5_Recipe named listOfRecipes * */ private ArrayList<SteppingStone5_Recipe> listOfRecipes; /** * Add accessor and mutator for listOfRecipes * */ public ArrayList<SteppingStone5_Recipe> getListOfRecipes() { return listOfRecipes; } public void setListOfRecipes(ArrayList<SteppingStone5_Recipe> listOfRecipes) { this.listOfRecipes = listOfRecipes; } /** *...
Below are the Car class and Dealership class that I
created In the previous lab
import java.util.ArrayList;
class Car
{
private String make;
private String model;
private int year;
private double transmission;
private int seats;
private int maxSpeed;
private int wheels;
private String type;
public Car()
{
}
public Car(String make, String model, int year, double transmission, int seats, int maxSpeed, int wheels, String type) {
this.make = make;
this.model = model;
this.year = year;
this.transmission = transmission;
this.seats =...
I need help with my code. It keeps getting this error:
The assignment is:
Create a class to represent a Food object. Use the
description provided below in UML.
Food
name : String
calories : int
Food(String, int) // The only constructor. Food name and
calories must be
// specified
setName(String) : void // Sets the name of the
Food
getName() : String // Returns the name of the
Food
setCalories(int) : void // Sets the calories of the
Food...