Create a program that will ask the user to enter the number of servings desired. Then generate the shopping list for all ingredients. Also calculate the leftover ingredients and the leftover cobbler Peaches come in cans of 29 ounces and 15 ounces Butter comes in packages of 1 pound (2 cups). Use a separate method to calculate and return the number of cans of peaches to buy. Use a separate method to calculate and return the boxes of butter. Output should look similar to the following. Spacing may vary, but make things line up! Fill in the numbers for the hashtags. USE VARIABLES. GROCERY LIST FOR <#> BATCHES OF COBBLER 29 ounce cans peaches ## 15 ounce cans peaches ## Yellow cake mixes ## pounds of butter QUANTITIES USED # # ounces of peaches used # # left over ##. # cups of butter used ##. # left over LEFTOVER COBBLER There should be <##> servings of cobbler left over, but don't count on it !

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

please help with this Java Lab. This is what i have so far

public static void main(String[] args) {
// TODO Auto-generated method stub
 
// Getting user input for num of servings
Scanner kb = new Scanner(System.in);
System.out.println("How many serving would you like to make?");
int servings = kb.nextInt();
 
//initialize other variables
double batch = servings /9;
 
 
}//end of main method
 
public static int calcPeaches(int batch) {
int peaches = batch *29;
return peaches;
}//end of calcPeaches
 
public static double calcButter(double batch) {
double butter = (3/8)*batch;
}
}
You have become the master of making peach cobbler. The recipe you follow is simple:
22 ounces of peaches in heavy syrup
1 regular yellow cake mix
3/8 cup melted butter
The biggest problem is making sure you have enough ingredients. The above recipe for one batch serves 9.
The cobbler is always made in the same batch size. There are no partial batches. Having some left over is ok,
but being short is not. It's also ok to have some peaches and some butter left over.
Create a program that will ask the user to enter the number of servings desired. Then generate the shopping
list for all ingredients. Also calculate the leftover ingredients and the leftover cobbler
Peaches come in cans of 29 ounces and 15 ounces
Butter comes in packages of 1 pound (2 cups).
Use a separate method to calculate and return the number of cans of peaches to buy.
Use a separate method to calculate and return the boxes of butter.
Output should look similar to the following. Spacing may vary, but make things line up!
Fill in the numbers for the hashtags. USE VARIABLES.
GROCERY LIST FOR <#> BATCHES OF COBBLER
# #
29 ounce cans peaches
##
15 ounce cans peaches
##
Yellow cake mixes
##
pounds of butter
QUANTITIES USED
##
left over
# #
ounces of peaches used
##. #
left over
##. #
cups of butter used
LEFTOVER COBBLER
There should be <##> servings of cobbler left over, but don't count on it!
Transcribed Image Text:You have become the master of making peach cobbler. The recipe you follow is simple: 22 ounces of peaches in heavy syrup 1 regular yellow cake mix 3/8 cup melted butter The biggest problem is making sure you have enough ingredients. The above recipe for one batch serves 9. The cobbler is always made in the same batch size. There are no partial batches. Having some left over is ok, but being short is not. It's also ok to have some peaches and some butter left over. Create a program that will ask the user to enter the number of servings desired. Then generate the shopping list for all ingredients. Also calculate the leftover ingredients and the leftover cobbler Peaches come in cans of 29 ounces and 15 ounces Butter comes in packages of 1 pound (2 cups). Use a separate method to calculate and return the number of cans of peaches to buy. Use a separate method to calculate and return the boxes of butter. Output should look similar to the following. Spacing may vary, but make things line up! Fill in the numbers for the hashtags. USE VARIABLES. GROCERY LIST FOR <#> BATCHES OF COBBLER # # 29 ounce cans peaches ## 15 ounce cans peaches ## Yellow cake mixes ## pounds of butter QUANTITIES USED ## left over # # ounces of peaches used ##. # left over ##. # cups of butter used LEFTOVER COBBLER There should be <##> servings of cobbler left over, but don't count on it!
Expert Solution
Step 1: Solution

Solution -

Programming language used: Java

 

Program code-

(Note: all solution steps are included in comments)

 

import java.util.Scanner;

public class PeachCobbler {
    public static void main(String[] args) {
       // Getting user input for num of servings
        Scanner kb = new Scanner(System.in);
        System.out.println("How many serving would you like to make?");
        int servings = kb.nextInt();
        kb.close(); // close scanner instance
         
        //initialize other variables
        double batch = Math.ceil((double)servings /9); // total number of batch required
       
        // call methods and display outputs
        System.out.println("\nGROCERY LIST FOR "+(int)batch+" BATCHES OF COBBLER\n");
        System.out.println(calcPeaches29(batch)+"\t29 ounce cans peaches");
        System.out.println(calcPeaches15(batch)+"\t15 ounce cans peaches");
        System.out.println((int)batch*1+"\tYellow cake mixes");
        System.out.println(calcButter(batch)+"\tpounds of butter");

       
        // calculate and display used and leftover ingredients
        int peaches = calcPeaches29(batch)*29+calcPeaches15(batch)*15; // total peaches purchased
        int butter = calcButter(batch)*2;

        System.out.println("\nQUANTITIES USED\n");
        System.out.println((int)batch*22+" ounces of peaches used\t"+(int)(peaches-batch*22)+" left over");
        System.out.println(batch*3/8+" cups of butter used\t"+(butter-batch*3/8)+" left over");


        // calculate and display leftover cobbler
        System.out.println("\nLEFTOVER COBBLER");
        System.out.println("\nThere should be "+(int)(batch*9-servings)+" servings of cobbler left over, but don't count on it!\n");
       
        }//end of main method
       
        // this method returns how many 29 ounces cans peaches required
        public static int calcPeaches29(double batch) {
            int peaches = (int) Math.floor(batch*(double)22/(double)29);
            return peaches;
        }
        //end of calcPeaches29 method

        // this method returns how many 15 ounces cans peaches required
        public static int calcPeaches15(double batch) {
            int peaches = (int) Math.ceil(((batch*22)- (calcPeaches29(batch)*29))/15);
            return peaches;
        }
        //end of calcPeaches15 method
       
        // calculate how many pounds of butter required
        public static int calcButter(double batch) {
            int butter = (int) Math.ceil(batch*3/8/2);
            return butter;
        }
        // end of calcButter method
}
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY