-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListaSpesa.java
More file actions
33 lines (23 loc) · 840 Bytes
/
ListaSpesa.java
File metadata and controls
33 lines (23 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.util.Scanner;
import java.util.ArrayList;
public class ListaSpesa {
public static void main (String[] args) {
ArrayList<String> listaDelleCoseDaFare = new ArrayList<String>();
System.out.println("Inserisci gli elementi per la lista quando richiesto");
boolean fatto = false;
Scanner tastiera = new Scanner (System.in);
while (!fatto) {
System.out.println("Inserisci un elemento:");
String elemento = tastiera.nextLine();
listaDelleCoseDaFare.add(elemento);
System.out.println("Vuoi aggiungere altri elementi?");
String risposta = tastiera.nextLine();
if (!risposta.equalsIgnoreCase("si"))
fatto= true;
}
System.out.println("La lista contiene:");
for (int i=0; i < listaDelleCoseDaFare.size(); i++) {
System.out.println(listaDelleCoseDaFare.get(i));
}
}
}