How to construct a grocery list using arrays that prints out the price, and quanity of the item? I am really stuck, I am in Java 1.
Program:
package HomeworkLib.answers;
import java.util.Scanner;
public class GroceryList {
public static void main(String args[]){
// arrays to store the item name, price and quantity
String[] item;
float[] price, quantity;
int n;
// creating scanner object to get input from user
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number of items: ");
// storing number of items
n = sc.nextInt();
// creating arrays of specified size
item = new String[n];
price = new float[n];
quantity = new float[n];
// loop to enter values in the arrays
for(int i = 0; i < n; i++){
System.out.println("Enter the item its price and quantity: ");
item[i] = sc.next();
price[i] = sc.nextFloat();
quantity[i] = sc.nextFloat();
}
System.out.println("GROCERY LIST: ");
System.out.println("Item:\t\tPrice:\t\tQuantity:");
// printing the arrays
for(int i = 0; i < n; i++){
System.out.println(item[i] + "\t\t" + price[i] + "\t\t" + quantity[i]);
}
}
}
Output:
Enter the number of items:
3
Enter the item its price and quantity:
Milk
10.2
6
Enter the item its price and quantity:
Eggs
7
12
Enter the item its price and quantity:
Bread
6.0
2
GROCERY LIST:
Item: Price:
Quantity:
Milk 10.2
6.0
Eggs 7.0
12.0
Bread 6.0
2.0
Screenshots:


Remove the "package HomeworkLib.answers;" line before executing. Also, describe a little more about the problem statement from next time.
Hope this helps!
How to construct a grocery list using arrays that prints out the price, and quanity of...
Count Occurrences in Seven Integers Using Java Single Dimension
Arrays
In this assignment,
you will design and code a Java console application that reads in
seven integer values and prints out the number of occurrences of
each value. The application uses the Java single dimension array
construct to implement its functionality.
Your program output
should look like the sample output provided in the "Count
Occurrences in Seven Integers Using Java Single Dimension Arrays
Instructions" course file resource. Full instructions for...
Problem 1: Dynamic Grocery Array Using Java to write a program that prompts the user to enter an item’s name for each position in the array. The program then prints uses a loop to output the array. Example 1: Banana 2: Orange 3: Milk 4: Carrot 5: Chips Banana, Orange, Milk, Carrot, Chips Problem 2: Print Characters in String Array Declare a string array of size 5. Prompt the user enters five strings that are stored in the array....
We are using GitLab and Python3 to recreate a Grocery List.
Using only print statements, variables, and arithmetic operations
how would I go about writing the code for such a project?
Grocery Items quantity price 1 $ total $ $ $ $ $ ՄԴ Item Apples Peanut Butter Cereal Campbells Soup Sweet Corn Barilla Pasta Laundry Detergent Pineapple chunks Canola Oil Coffee Prego Sauce Rigatoni Quaker Oats LED Light Bulbs Դ onwnowpA 0 G ono tttttttttttttttttttt 5.92 6.66 3.64 0.98...
I need a java program that prints the positive numbers of a list of 5 numbers, 4, 1, -8, 20, -19 using keyboard
I need a java program that prints the negative numbers from the list of 5 numbers 2, 1, -6, 18, -17 (-18 to -1) using dialog box
Write a program to keep track of the inventory of grocery store. Write a test program that prompts the user to enter how many items of inventory the store has. After that enter item name, quantity and price of each item in three different arrays called Itemname, Quantity and Price. Than calculate the Total=Quantity*Price of items in store and FinalTotal of all the items and print in following exact format using array: Sample run of program: Enter number of items...
PART 1 Modify the class ArrayList given in Exercise 1 by using expandable arrays. That is, if the list is full when an item is being added to this list, the elements will be moved to a larger array. The new array should have twice the size of the original array. Using the new class ArrayList, write a program to store 1,000 random numbers, each in the interval [0, 500]. The initial size of the array in the class should...
Write a Java class myLinkedList to simulate a singly linked list using arrays as the underlying structure. Include the following methods: 1. insert an element within the linked list.(this should also work for the front and the rear of the list) 2. Remove an element from the linked list 3. Display (print) the elements of the linked list in order. 4. A method to check if the list is "empty". Test your solution using a linked list that initially has...
How to write MIPS function that recursively prints out linked list that takes one argument (address of firstNode), and is separated by commas.
use java thanks 1.Given the following arrays, write a Java program to generate the output below. String [] item = {"milo", "water", "coke", "tea", "coffee"}; double [] price = {3.00, 1.00, 5.00, 2.00, 3.50}; int [] quantity = {200, 500, 350, 100, 700}; Re-write Question 1 using array list and display the sale of the day report. Re-write Question 1 using 2-dimensional array and display the sale of the day report. Write a segment program to replace...