Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Your Java program will have (in Eclipse) the Java project name “ Ryebread \" and

ID: 3819464 • Letter: Y

Question

Your Java program will have (in Eclipse) the Java project  name Ryebread" and the class name Ryebread"

Standard assignment labeling rules apply for Ryebread

(Student  name in the first line of the program code as a comment ; and (prints to console) when it runs .)

Upload your completed .Java   file in Canvas for this assignment

Use appropriate data type for all variables – double, int….. also   (// use comments ).

Have a variable at the beginning named “quantity", so you can edit it to change quantity of loavs (Individually pick a number from 4 to 10. for quantity of loaves of bread).

Use variables with appropriate names for each ingredient (e.g. yeast).

When the program runs, it prints out an ingredient list, listing the total amount required for each ingredient (based on the amount required for one loaf) for your assigned quantity of loaves, to the console. Use System.out.println, System.out.printf and System.out.print to output your results. Format your output so that values are rounded (and outputted) to the nearest tenth (.1) of a gram. Be sure to include units in your output.

Ingredients required for  1.0 loaves:
yeast=7.23;

sugar=12.33;

butter=43;

milk=250.5;

salt=9.22;

ryeFlour=100;

allPurposeFlour=310;

carawaySeeds=7.3;

vegOil=15;

For example output to console should look like

Rye bread assignment Peter Baker

Ingredients for  2.0 loaves:
yeast
= 14.5 grams
sugar = 24.7 grams
:

Explanation / Answer

Ryebread.java

import java.text.DecimalFormat;
import java.util.Scanner;

public class Ryebread {

   public static void main(String[] args) {
       //intialize values to each of the ingrediants for 1 loave.
       int quantity =5;//initial quantity
       double yeast =7.23;
       double sugar=12.23;
       double butter=43;
       double milk=250.5;
       double salt=9.22;
       int ryeFlour=100;
       int allPurposeFlour=310;
       double carawaySeeds=7.3;
       int vegOil=15;
       //To read the value for number of loaves given in console
   //   Scanner input = new Scanner(System.in);
   //   System.out.print("Please enter an number of loaves required: ");
      
       //Set the value given in console for number of loaves.
   //   quantity = input.nextInt();
      
       DecimalFormat df=new DecimalFormat("0.0");//format to nearest 10th
       System.out.println("Rye bread assignment Peter Baker");
       System.out.println("Ingrediants for "+quantity+" loaves");
       System.out.println("yeast = "+df.format(yeast*quantity)+" grams");//df.format(double) method is used to round off to nearest tenth(.1)
       System.out.println("sugar = "+df.format(sugar*quantity)+" grams");
       System.out.println("butter = "+butter*quantity+" grams");
       System.out.println("milk = "+df.format(milk*quantity)+" ml");
       System.out.println("salt = "+df.format(salt*quantity)+" grams");
       System.out.println("ryeFlour = "+ryeFlour*quantity+" grams");
       System.out.println("allPurposeFlour = "+allPurposeFlour*quantity+" grams");
       System.out.println("carawaySeeds = "+df.format(carawaySeeds*quantity)+" grams");
       System.out.println("vegOil = "+vegOil*quantity+" ml");
      
      
   }
}

Output using console input

Please enter an number of loaves required: 2
Rye bread assignment Peter Baker
Ingrediants for 2 loaves
yeast = 14.5 grams
sugar = 24.5 grams
butter = 86.0 grams
milk = 501.0 ml
salt = 18.4 grams
ryeFlour = 200 grams
allPurposeFlour = 620 grams
carawaySeeds = 14.6 grams
vegOil = 30 ml

Output by using quantity variable:

Rye bread assignment Peter Baker
Ingrediants for 5 loaves
yeast = 36.2 grams
sugar = 61.2 grams
butter = 215.0 grams
milk = 1252.5 ml
salt = 46.1 grams
ryeFlour = 500 grams
allPurposeFlour = 1550 grams
carawaySeeds = 36.5 grams
vegOil = 75 ml

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote