Create a recipe, with at least five ingredients, in pseudocode for your specialt
ID: 3880198 • Letter: C
Question
Create a recipe, with at least five ingredients, in pseudocode for your specialty. You can assume that:
1.All ingredients are available and accessible to the user.
2.The person reading the recipe will know how to measure, pour, etc.
3.The person is literal.
4.There is no alternative to ingredients.
5.You need to allow for a change in the number of people (i.e. your recipe may be for 4 people, but the person reading the recipe may need to double or triple it. Your program should ask for a number of people and compute the multiplying factor).
6.When the user runs the program, the recipe will be printed, with all necessary steps from start to finish.
LAST: Write the same program in Java. The program should have a header, comments, compile and run correctly submit as a (java file)
Explanation / Answer
here is your java program : -------------------->>>>>>>>>>>>
import java.util.Scanner;
class Recipe{
private int[] gredient;
private String[] gredientName;
private int count = 0;
public Recipe(){
gredient = new int[5];
gredientName = new String[5];
}
public add(String name,quantity){
if(count < 5){
gredient[count] = quantity;
gredientName = name;
count++;
}
}
public void calculate(int n){
for(int i = 0;i<count;i++){
gredient[i] = gredient[i]*n/4;
}
}
public void print(){
System.out.println("HERE IS THE INSTRUCTION FOR THE RECIPE");
for(int i = 0;i<count;i++)
System.out.println("take the "+gredientName[i]+" of Quantity "+gredient[i]+"gm");
}
public static void main(String[] args){
Recipe r1 = new Recipe();
r1.add("garlic",20);
r1.add("chilli",10);
r1.add("capsicum",500);
r1.add("potato",500);
r1.add("Paneer",200);
r1.print();
Scanner sc = new Scanner(System.in);
System.out.println("Enter the Number Of People");
int n = sc.nextInt();
r1.calculate(n);
r1.print();
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.