Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Each class contains at least one error. There are five total errors across all four classes. Please identify all errors and explain what must be

Each class contains at least one error. There are five total errors across all four classes. Please identify all errors and explain what must be done to correct each error. Once you fix all the errors provide me with the output for the program.

Below is the source code for all four files:

package package1;

public abstract class Beverage {

private int ounces;

private double price;

Beverage(int ounces, double price) {

this.ounces = ounces;

this.price = price;

}

public int getOunces() { return ounces; }

public double getPrice() { return price; }

public abstract String drink();

}

package package1;

public class IceWater implements Beverage {

public IceWater(int ounces, double price) {

super(ounces, price);

}

public String drink() {

return "This ice water is cool and refreshing.";

}

}

package package2;

import package1.*;

public class HotTea implements Beverage {

public HotTea(int ounces, double price) {

super(ounces, price);

}

public String drink() {

return "This tea is hot and soothing.";

}

}

package package2;

static import java.lang.System.out;

public class TestBeverage {

public static void main(String[] myListOfArgs) {

IceWater drink1 = new IceWater(16, 1.00);

HotTea drink2 = new HotTea(10, 2.99);

out.print("The water is " + drink1.getOunces() + " ounces ");

out.println("and costs $" + drink1.getPrice() + ".");

out.println(drink1.drink());

out.print("The tea is " + drink2.getOunces() + " ounces ");

out.println("and costs $" + drink2.getPrice() + ".");

out.println(drink2.drink());

}

}

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

Step: 3

blur-text-image

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

Business Essentials

Authors: Ronald J. Ebert, Ricky W. Griffin

10th edition

978-0133454420, 133454428, 978-0133771558

More Books

Students also viewed these Programming questions

Question

Why are small businesses important to the U.S. economy?

Answered: 1 week ago

Question

What are the five forces in the external marketing environment?

Answered: 1 week ago

Question

Calculate the missing value.

Answered: 1 week ago