Question: THIS IS JAVA public class Grocery { //Instance Variables private double item1; private double item2; //Default Constructor public Grocery() { this.item1 = 0.0; this.item2 =

THIS IS JAVA

public class Grocery {

//Instance Variables

private double item1;

private double item2;

//Default Constructor

public Grocery() {

this.item1 = 0.0;

this.item2 = 0.0;

}

//Constructor w/ parameters

public Grocery(double value1, double value2) {

this.setItem1(value1);

this.setItem2(value2);

}

//Getter and Setter methods

public double getItem1() {

return this.item1;

}

public void setItem1(double value1) {

this.item1 = value1;

}

public double getItem2() {

return this.item2;

}

public void setItem2(double value2) {

this.item2 = value2;

}

public double compute() {

double result = Math.abs(item1 * Math.sqrt(item2));

return result;

}

}

What is worng with my class? I keep getting an error.

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!