Question: Please Help, Add the class CoffeeBeanOrder below CoffeeBeanOrder _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ - weight:double

Please Help, Add the class CoffeeBeanOrder below
CoffeeBeanOrder
_______________
-weight:double
-quality:int
_______________
+ CoffeeBeanOrder()
+ CoffeeBeanOrder(double,int)
+ setWeight(double):void
+ getWeight():double
+ setQuality(int):void
getQuality(): int
+ calcCost():double
+ calcShipping(): double
+ toString(): String
_________________
Additional specifications:
The CoffeeBeanOrder() no arg constructor should set both fields to zero.
The parameterized constructor should have parameters ordered:
CoffeeBeanOrder (double weight, int quality)
The integer quality field is defined as:
1 Marginal
2 Good
3 Best
Calculate theorder cost using the following:
Margin coffee: $8.99/pound
Good coffee: $14.99/pound
Best coffee: $24.99/pound
Calculate the shipping cost as: $3.99/pound
Method toString() should return a String (in a format of your choice) that contains the current values of weight and quality, but report Marginal,Good, or Bad instead of the integer value for quality. Add the above to the program below. public class TestCoffee
{
public static void main( String args[])
{
// Test no-arg constructor
CoffeeBeanOrder order1= new CoffeeBeanOrder();
System.out.println(order1);
// Test setters, toString(), and calculations
order1.setWeight(3.1);
order1.setQuality(1);
System.out.println(order1);
System.out.println(order1.calcCost());
System.out.println(order1.calcShipping());
// Test parameterized constructor, and calculations
CoffeeBeanOrder order2= new CoffeeBeanOrder(7.2,2);
System.out.println(order2);
System.out.println(order1.calcCost());
System.out.println(order1.calcShipping());
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!