Question: In Java program Write a driver that creates the following three fruits Fruit b = new Fruit(banana, 94,0.20,0.50); Fruit a = new Fruit(apple,52,0.10,0.45); Fruit or
In Java program Write a driver that creates the following three fruits
Fruit b = new Fruit("banana", 94,0.20,0.50);
Fruit a = new Fruit("apple",52,0.10,0.45);
Fruit or = new Fruit("orange",86,0.20,0.55);
Then have it calculate and print out the fruit with the lowest cost per kilogram. Your output should look similar to mine.
A typical banana weights 0.2 kilograms, has 94 calories and costs $0.50 each
The cost per kg is $2.50 and the calories per kg is 470.0
A typical apple weights 0.1 kilograms, has 52 calories and costs $0.45 each
The cost per kg is $4.50 and the calories per kg is 520.0
A typical orange weights 0.2 kilograms, has 86 calories and costs $0.55 each
The cost per kg is $2.75 and the calories per kg is 430.0
A banana has the lowest cost per kg Here is the UML diagram which summarize a blueprint
AND HERE IS SAMPLE OUTPUT BELOW
> Fruit quzweek7 -type: String numCalories: int kgWeight double cost: double & Fruit Fruit(String int, double double) toStringo String costPerkg0:double calPerkg():double getType(): String o setType(String) void getNumCalories()int setNumCalories(int):void getkgWeight():double setgWeight(double):void getCost().double setCost(double) void Fruit/FruitDriver A typical banana weights 0.2 kilograms, has 94 calories and costs $0.50 each The cost per kg is $2.50 and the calories per kg is 470.0 A typical apple weights 0.1 kilograms, has 52 calories and costs $0.45 each The cost per kg is $4.50 and the calories per kg is 520.0 A typical orange weights 0.2 kilograms, has 86 calories and costs $0.55 each The cost per kg is $2.75 and the calories per kg is 430.0 A banana has the lowest cost per kg
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
