How do I write pseudocode for this? I am confused. I started writing pseudocode but i'm not
Question:
How do I write pseudocode for this? I am confused. I started writing pseudocode but i'm not sure if it is correct. Also, the code I received help for is below starting with *****recipe****.
*****WritePseudocode****
Create and initialize new String "recipeName"
Arraylist String "recipeIngredients"
Private int "totalRecipeCalories"
Do
Prompts the user to "enter the recipe name"
Add input to Arraylist
Prompts user to "enter number of servings"
It will then ask if the user wants to enter more information or type "end" if you are finished.
Loop to be used if to add more ingredients
***********Recipe***********
package Recipe;
import java.util.Scanner;
import java.util.ArrayList;
/** * * @author rbell */ class Recipe {
private String recipeName; private int servings; ArrayList
/** * * @param recipeName */ public void setRecipeName(String recipeName) { this.recipeName = recipeName; }
/** * * @return */ public String getRecipeName() { return recipeName; }
/** * * @param servings */ public void setServings(int servings) { this.servings = servings; }
/** * * @return */ public int getServings() { return servings; }
/** * * @param recipeIngredients */ public void setRecipeIngredients(ArrayList
/** * * @return */ public ArrayList
/** * * @param totalRecipeCalories */ public void setTotalRecipeCalories(int totalRecipeCalories) { this.totalRecipeCalories = totalRecipeCalories; }
/** * * @return */ public int getTotalRecipeCalories() { return totalRecipeCalories; }
/* Constructors to use for preset fields */
public Recipe() { this.recipeName = ""; this.servings = 0; this.recipeIngredients = new ArrayList
/** * * @param recipeName * @param servings * @param recipeIngredients * @param totalRecipeCalories */ public Recipe(String recipeName, int servings, ArrayList
/* Method used to Print the Recipe Details */
public void printRecipe() { int singleServingCalories = (totalRecipeCalories / servings); System.out.println(" Recipe: " + recipeName); System.out.println("Serves: " + servings); System.out.println("Ingredients: "); for (int i = 0; i < recipeIngredients.size(); i++) { String ingredient = recipeIngredients.get(i); System.out.println(ingredient); } System.out.println("Each Serving Has " + singleServingCalories + " Calories."); } //Method to create a New Recipe so that you can Build Recipes Based on the User's Input
/** * * @param args * @return */
public Recipe addNewRecipe() { //bint totalRecipeCalories = 0; ArrayList
*******RecipeTest****
package Recipe;
/** * * @author rbell */ public class RecipeTest {
/** * @param args the command line arguments */ public static void main(String[] args) { final Recipe newRecipe = new Recipe(); //Constructor used to create the new Recipe newRecipe.addNewRecipe(); //Invoke function to addNewRecipe() newRecipe.printRecipe(); //Access used to printRecipe() } } **************************************
Create and initialize new String "recipeName"
Arraylist String "recipeIngredients"
Private int "totalRecipeCalories"
Do
Prompts the user to "enter the recipe name"
Add input to Arraylist
Prompts user to "enter number of servings"
It will then ask if the user wants to enter more information or type "end" if you are finished.
Loop to be used if to add more ingredients
Modern Advanced Accounting in Canada
ISBN: 978-1259087554
8th edition
Authors: Hilton Murray, Herauf Darrell