Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main;
- import java.io.FileNotFoundException;
- import java.io.PrintWriter;
- import java.util.ArrayList;
- import java.util.Scanner;
- public class Main {
- /**
- * @param args
- * @throws FileNotFoundException
- */
- public static void main(String[] args) throws FileNotFoundException
- {
- ArrayList<Cassieri> c=new ArrayList<Cassieri>();
- Cassieri tm=new Cassieri();
- Scanner t = new Scanner(System.in);
- PrintWriter pw = new PrintWriter("archivio.txt");
- int n,i;
- System.out.print("Quanti cassieri vuoi aggiungere? -> ");
- n=t.nextInt();
- t.useDelimiter("\n");
- for(i=0;i<n;++i)
- {
- System.out.println(i+"\n");
- Cassieri tmp = new Cassieri();
- tmp.setNomeCognome(t.next());
- tmp.setEta(t.nextInt());
- tmp.setAnniLavoro(t.nextShort());
- tmp.setValoreCassa(t.nextInt());
- c.add(i, tmp);
- }
- for(i=0;i<c.size();i++)
- {
- tm=c.get(i);
- pw.println(tm.getNomeCognome()+","+tm.getAnniLavoro()+","+tm.getEta()+","+tm.getValoreCassa()+"\n");
- System.out.print(tm.getNomeCognome()+","+tm.getAnniLavoro()+","+tm.getEta()+","+tm.getValoreCassa()+"\n");
- }
- pw.close();
- }
- }
Add Comment
Please, Sign In to add comment