Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please Help, Use the code below. CoffeeBeanOrder _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ - weight:double -

Please Help, Use the code 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. 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security

Authors: Alfred Basta, Melissa Zgola

1st Edition

1435453905, 978-1435453906

More Books

Students also viewed these Databases questions

Question

Describe Moore's rule.

Answered: 1 week ago