Note that there are some explanatory texts on larger screens.

plurals
  1. POincompatible types found : double
    primarykey
    data
    text
    <p>i am trying to write a program, and the rest of the code so far works but i am getting a incompatible types found : double required :Grocery Item in line 38. Can anyone help me in explaining why I am receiving this error and how to correct it? Thank you. here is my code: </p> <pre><code> import java.util.Scanner; public class GroceryList { private GroceryItem[]groceryArr; //ARRAY HOLDS GROCERY ITEM OBJECTS private int numItems; private String date; private String storeName; public GroceryList(String inputDate, String inputName) { //FILL IN CODE HERE // CREATE ARRAY, INITIALIZE FIELDS groceryArr = new GroceryItem[10]; numItems = 0; } public void load() { Scanner keyboard = new Scanner(System.in); double sum = 0; System.out.println ("Enter the trip date and then hit return:"); date = keyboard.next(); keyboard.nextLine(); System.out.println("Enter the store name and then hit return:"); storeName = keyboard.next(); keyboard.nextLine(); double number = keyboard.nextDouble(); //NEED TO PROMPT USER FOR, AND READ IN THE DATE AND STORE NAME. System.out.println("Enter each item bought and the price (then return)."); System.out.println("Terminate with an item with a negative price."); number = keyboard.nextDouble(); while (number &gt;= 0 &amp;&amp; numItems &lt; groceryArr.length) { groceryArr[numItems] = number; numItems++; sum += number; System.out.println("Enter each item bought and the price (then return)."); System.out.println("Terminate with an item with a negative price."); number = keyboard.nextDouble(); } /* //READ IN AND STORE EACH ITEM. STORE NUMBER OF ITEMS } private GroceryItem computeTotalCost() { //add code here } public void print() { \\call computeTOtalCost } */ } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload