Question: A program that calculates the amount of ingredients needed for various flavors of cheesecake. A07.02Assignmentproject in the Mod07Assignments folder. Carefully read the instructions before you
A program that calculates the amount of ingredients needed for various flavors of cheesecake.
- A 07.02 Assignment project in the Mod07 Assignments folder.
- Carefully read the instructions before you attempt the assignment.
- You will benefit from writing a pseudocode algorithm and a class diagram before you actually start writing code.
- Create two new classes named CheeseCake and CheeseCakeTester.
- The program should be written in OOP format. An ArrayList filled with objects of the CheeseCake class is needed as part of the design.
- Use the following constructor header for the CheeseCake class.
- CheeseCakeV2(String flavor,int quantity)
- Your program should include the following methods:
- public void calcTotalServings()
- public void calcCreamCheese()
- public void calcSugar()
- public void calcVanila()
- Values to be used in the calculations can be reviewed in the Background Information section below.
- Add records for at least six cheesecakes to the ArrayList. A sample set of values could be: Blueberry, 4. This represents 4 blueberry flavored cheesecakes.
- Print the results in a user-friendly format (see expected output).
Background Information:
- Cheesecakes are a very versatile dessert! Making a "base batter" affords you the opportunity to make a variety of cake "flavors" by either changing toppings or mixing the extra ingredient in with the batter. Some unusual combinations are quite tasty.
- A basic 9-inch cheesecake serves 16 people and has the following ingredients:
- 32 ounces of cream cheese
- 1/3 cup of sugar
- 1 teaspoon of Vanilla flavoring
- Before you try to make any calculation statements, make sure you can reproduce with a calculator the results shown in the expected output.
Expected Output: When your program runs correctly, you should see output similar to the following screen shot:
Codes to use as a guide:
CheeseCakeTestV1:
/**
* @purpose
*
* @author (enter your name)
* @version (enter today's date)
*
*/
import java.util.ArrayList;
public class CheeseCakeTesterV1
{
public static void main(String[] args)
{
//initializing and declaring an ArrayList and adding in objects as elements
ArrayList cake = new ArrayList();
// add CheeseCake to the ArrayList
//calls several method for each object to perform calculations
for(CheeseCakeV1 dataRecord : cake)
{
// invoke methods
}
//printing the format of the table
System.out.println("| Cheese Cake Data | Ingredient Calculations |");
System.out.println(" | Index | Quantity | Flavor | Cream Cheese | Servings | Sugar | Vanilla |");
System.out.println(" |-------|----------|---------------|--------------|----------|-----------|-----------|");
CheeseCakeV1 dataRecord;
//using a for loop to print out the objects' data
for(int index = 0; index
{
// print each CheeseCake's data
}
}
}
CheeseCakeV1:
/**
* @purpose
*
* @author (enter your name)
* @version (enter today's date)
*
*/
public class CheeseCakeV1
{
private int myQuantity, myServings, myCreamCheese, myVanilla;
private double mySugar;
private String myFlavor;
/**
* Constructor for objects of type CheeseCakeV1
* @param flavor
* @param quantity
*/
CheeseCakeV1(String flavor,int quantity)
{
//******* fill in code for constructor here ****//
}
/**
* Mutator method to calculate the number of servings
*/
public void calcTotalServings()
{
//******* fill in code for method here - 16 servings per cake ****//
}
/**
* Mutator method to calculate the Cream Cheese Needed
*/
public void calcCreamCheese()
{
//******* fill in rest of method here - 32 ounces per cake ****//
}
/**
* Mutator method to calculate the Vanilla Needed
*/
public void calcVanilla()
{
//******* fill in rest of method here - 1 teaspoon per cake ****//
}
/**
* Mutator method to calculate the Sugar Needed
*/
public void calcSugar()
{
//******* fill in rest of method here - 1/3 cup per cake ****//
}
/**
* Getter method to return the number of cakes (no parameters)
*/
public int getquantity()
{
return myQuantity;
}
/**
* Getter method to return flavor of the cake (no parameters)
*/
public String getFlavor()
{
return myFlavor;
}
/**
* Getter method to return amount of Sugar needed (no parameters)
*/
public double getSugar()
{
return mySugar;
}
/**
* Getter method to return amount of Cream Cheese needed (no parameters)
*/
public int getCreamCheese()
{
return myCreamCheese;
}
/**
* Getter method to return amount of Vanilla needed (no parameters)
*/
public int getVanilla()
{
return myVanilla;
}
/**
* Getter method to return number of Servings (no parameters)
*/
public int getServings()
{
return myServings;
}
public String toString()
{
//******* Practice your printf() skills by formatting this data! ****//
return String.format("The data that matches the headings in the CheeseCakeV1 file");
}
}
Bluel: Terminal Window - 7.02 APCS Options Cheese Cake Data Index | Quantity | Flavor 0 1 2 3 4 I 1 | I 5 6 4 1 2 3 | Blueberry | Strawberry | Cherry | Jalapeno | Dill Pickle | Fig Ingredient Calculations Cream Cheese | Servings | Sugar | Vanilla 160 oz 192 oz 128 oz 32 oz 64 oz 96 oz 80 96 64 16 32 48 | 1.67 | 2.00 | 1.33 | 0.33 | 0.67 | 1.00 cups | cups | cups | cups | cups | cups 5 tsps 6 tsps 4 tsps 1 tsps 2 tsps 3 tsps X
Step by Step Solution
There are 3 Steps involved in it
CheeseCakeV1java public class CheeseCakeV1 private int myQuantity myServings myCreamCheese myVanilla private double mySugar private String myFlavor Constructor for objects of type CheeseCakeV1 param f... View full answer
Get step-by-step solutions from verified subject matter experts
