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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started