0
How to create grocery list in java
With codes 😌 🙏
13 Antworten
+ 5
Flonie Ballenas
Take an arraylist and add items.
+ 3
Try it first by yourself.... and post your try....
+ 1
Then it will lost the Peso sign?
+ 1
Thank you
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
0
I make it public already
0
AJ can you message to me directly the codes? I cant copy it
- 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);
}
}