Guest User

Untitled

a guest
Feb 19th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.14 KB | None | 0 0
  1. package main;
  2.  
  3. import java.io.FileNotFoundException;
  4. import java.io.PrintWriter;
  5. import java.util.ArrayList;
  6. import java.util.Scanner;
  7.  
  8. public class Main {
  9.  
  10.     /**
  11.      * @param args
  12.      * @throws FileNotFoundException
  13.      */
  14.     public static void main(String[] args) throws FileNotFoundException
  15.     {
  16.         ArrayList<Cassieri> c=new ArrayList<Cassieri>();
  17.         Cassieri tm=new Cassieri();
  18.         Scanner t = new Scanner(System.in);
  19.        
  20.         PrintWriter pw = new PrintWriter("archivio.txt");
  21.        
  22.         int n,i;
  23.         System.out.print("Quanti cassieri vuoi aggiungere? -> ");
  24.         n=t.nextInt();
  25.        
  26.         t.useDelimiter("\n");
  27.         for(i=0;i<n;++i)
  28.         {  
  29.             System.out.println(i+"\n");
  30.             Cassieri tmp = new Cassieri();
  31.             tmp.setNomeCognome(t.next());
  32.             tmp.setEta(t.nextInt());
  33.             tmp.setAnniLavoro(t.nextShort());
  34.             tmp.setValoreCassa(t.nextInt());
  35.             c.add(i, tmp);
  36.         }
  37.        
  38.         for(i=0;i<c.size();i++)
  39.         {
  40.             tm=c.get(i);
  41.                 pw.println(tm.getNomeCognome()+","+tm.getAnniLavoro()+","+tm.getEta()+","+tm.getValoreCassa()+"\n");
  42.    
  43.             System.out.print(tm.getNomeCognome()+","+tm.getAnniLavoro()+","+tm.getEta()+","+tm.getValoreCassa()+"\n");
  44.         }
  45.         pw.close();
  46.     }
  47. }
Add Comment
Please, Sign In to add comment