0

How to create grocery list in java

With codes 😌 🙏

9th Dec 2020, 2:00 PM
Flonie Ballenas
Flonie Ballenas - avatar
9 Answers
+ 5
Flonie Ballenas Take an arraylist and add items.
9th Dec 2020, 2:31 PM
A͢J
A͢J - avatar
+ 3
Try it first by yourself.... and post your try....
9th Dec 2020, 2:13 PM
Jayakrishna 🇮🇳
+ 1
Then it will lost the Peso sign?
9th Dec 2020, 5:10 PM
Flonie Ballenas
Flonie Ballenas - avatar
+ 1
Thank you
9th Dec 2020, 5:41 PM
Flonie Ballenas
Flonie Ballenas - avatar
0
I already did but it has an errors in class name. It states that the class name is wrong even though i check it a lot of times
9th Dec 2020, 4:10 PM
Flonie Ballenas
Flonie Ballenas - avatar
0
I make it public already
9th Dec 2020, 4:32 PM
Flonie Ballenas
Flonie Ballenas - avatar
0
AJ can you message to me directly the codes? I cant copy it
9th Dec 2020, 5:13 PM
Flonie Ballenas
Flonie Ballenas - avatar
- 1
Flonie Ballenas You can do using while loop. You can take multiple input and calculate total using loop. This is a pure solution of your problem:- ------------- import java.util.Scanner; public class GroceryList { public static void main(String[] args) { double[] prices = new double[5]; Scanner in = new Scanner(System.in); System.out.println("Enter 5 prices: "); int i = 0; while (i < 5) { prices[i] = in.nextDouble(); i++; } double total = 0.00; for (double amount : prices) { total += amount; } System.out.printf("The total for all 5 items is: ₱%2f", total); } }
9th Dec 2020, 4:50 PM
A͢J
A͢J - avatar