Advertisement
Guest User

Untitled

a guest
Jan 14th, 2020
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class calcio1
  3. {
  4. static Scanner scanner = new Scanner (System.in);
  5. public static int n=0, i=0, j=0;
  6.  
  7. static String [] nome = new String [3];
  8. static String [] cognome = new String [3];
  9. static String [] squadra = new String [3];
  10. static String [] ruolo = new String [3];
  11. static int [] goal = new int [3];
  12.  
  13. /*static String[] nome;
  14. static String[] cognome;
  15. static String[] squadra;
  16. static String[] ruolo;
  17. static int[] goal;*/
  18. static int scelta1;
  19.  
  20. public static void main(String[] args)
  21. {
  22. /*nome = new String[3];
  23. cognome = new String[3];
  24. squadra = new String[3];
  25. ruolo = new String[3];
  26. goal = new int[3];*/
  27.  
  28. carica_interno();
  29. do
  30. {
  31. System.out.println("\t\tMENU'");
  32. System.out.println("1 - Visualizzare il nome del calciatore che ha fatto piu' goal");
  33. System.out.println("2 - Visualizzare i calciatori di una squadra");
  34. System.out.println("3 - Visualizzare i calciatori suddivisi per ruolo");
  35. System.out.println("Inserisci la tua scelta: ");
  36. int scelta = scanner.nextInt();
  37.  
  38. switch(scelta)
  39. {
  40. case 1:
  41. piu_goal();
  42. break;
  43.  
  44. /*case 2:
  45. giocatori_squadra();
  46. break;
  47.  
  48. case 3:
  49. visualizza_ruolo();
  50. break;*/
  51.  
  52. }
  53. System.out.print("\nVuoi continuare si(0) no(1): ");
  54. scelta1=scanner.nextInt();
  55.  
  56. }while(scelta1==0);
  57.  
  58.  
  59. }
  60.  
  61. public static void carica_interno()
  62. {
  63. n=3;
  64. nome[0]="Cristiano"; cognome[0]="Ronaldo"; squadra[0]="Juventus"; ruolo[0]="Attaccante"; goal[0]=10;
  65. nome[1]="Paulo"; cognome[1]="Dybala"; squadra[1]="Juventus"; ruolo[1]="Attaccante"; goal[1]=16;
  66. nome[2]="Federico"; cognome[2]="Bernardeschi"; squadra[2]="Juventus"; ruolo[2]="Attaccante"; goal[2]=10;
  67. }
  68.  
  69. public static void piu_goal()//funzione 1
  70. {
  71. int max=0;
  72. int imax=0;
  73. for(i=0;i<n;i++)
  74. {
  75. if(max<goal[i])
  76. {
  77. goal[i]=max;
  78. imax=i;
  79. }
  80. }
  81. System.out.println("Giocatore: " + nome[i] + " " + cognome[i]);
  82. System.out.println("Numero goal: " + goal[i]);
  83. }
  84.  
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement