Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions

Question

How do you add two harmonic motions having different frequencies?

Answered: 1 week ago