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

Write a class named blend. The blend class should contain me the quantity of the

ID: 3778517 • Letter: W

Question

Write a class named blend. The blend class should contain me the quantity of the total coffee in the blend (in pounds), the time of the roast (in hours use a double) of the blend, the name of the blend, and predicted yield in gallons of the blend. Each blend may contain up to three different coffees and will contain the pounds of each used. The blend should have a constructor and applicable methods and be able to display each of the coffees used in the blend via the methods called in any instance. (You should use aggregation in this class)

notes:- Your demo should include a an array of 3 blends. you should be able to generate a report of all blends including blend name, each of the coffee and percentage of each used, as well as average caffine_index.

no

Explanation / Answer

Coffee.java

public class Coffee{
    double poundsUsed;
    String name;
    public Coffee(double poundsUsed, String name){
        this.poundsUsed = poundsUsed;
        this.name = name;
    }
}

Blend.java

public class Blend{
    double totalCoffee;
    double time;
    String name;
    double yield;
    Coffee coffees[] = new Coffee[3];

    public Blend(double totalCoffee, double time, String name, double yield, Coffee coffees[]){
        this.totalCoffee = totalCoffee;
        this.time = time;
        this.name = name;
        this.yield = yield;
        this.coffees = coffees;
    }

    public double getTotalCoffee(){
        return this.totalCoffee;
    }

    public double getYield(){
        return this.yield;
    }

    public double getTime(){
        return this.time;
    }

    public String getName(){
        return this.name;
    }

    public Coffee[] getCoffees(){
        return this.coffees;
    }

    public static void main(String[] args) {

        Blend blends[] = new Blend[3];
        Coffee coffees1[] = new Coffee[3];
        Coffee coffees2[] = new Coffee[3];
        Coffee coffees3[] = new Coffee[3];
        coffees1[0] = new Coffee(12, "coffee11");
        coffees1[1] = new Coffee(13, "coffee12");
        coffees1[2] = new Coffee(14, "coffee13");
        blends[0] = new Blend(25, 20.0, "blend1", 123, coffees1);
        coffees2[0] = new Coffee(12, "coffee21");
        coffees2[1] = new Coffee(13, "coffee22");
        coffees2[2] = new Coffee(14, "coffee23");
        blends[1] = new Blend(22, 28.0, "blend2", 125, coffees2);
        coffees3[0] = new Coffee(20, "coffee31");
        coffees3[1] = new Coffee(122, "coffee32");
        coffees3[2] = new Coffee(18, "coffee33");
        blends[2] = new Blend(250, 150.0, "blend3", 12, coffees3);

        System.out.println("First blend name: " + blends[0].getName());
        System.out.println("Second blend name: " + blends[1].getName());
        System.out.println("Third blend name: " + blends[2].getName());


    }
}

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