Advertisement
Guest User

Untitled

a guest
Aug 4th, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.22 KB | None | 0 0
  1. import java.io.*;
  2.  
  3. /*Algoritmo Voti
  4. INIZIO
  5.     PER i DA 0 A numeroVoti-1
  6.         leggi(voto)
  7.         SE voto < 6
  8.             ALLORA
  9.             testo = "negativo"
  10.             ALTRIMENTI
  11.                 SE voto == 6
  12.                     ALLORA
  13.                         testo = "sufficiente"
  14.                     ALTRIMENTI
  15.                         testo = "positivo"
  16.         scrivi(testo)
  17. FINE*/
  18.  
  19. class Voti{
  20.     public static void main(String args[]){
  21.         int i;
  22.         int numeroVoti;
  23.         int voto;
  24.         InputStreamReader input = new InputStreamReader(System.in);
  25.         BufferedReader tastiera = new BufferedReader(input);
  26.         try{
  27.             System.out.println("Quanti voti bisogna esaminare?");
  28.             String nVoto = tastiera.readLine();
  29.             numeroVoti = Integer.valueOf(nVoto).intValue();
  30.             for(i=1; i <= (numeroVoti); i++){
  31.                 try{
  32.                     System.out.println("Quali sono?");
  33.                     String votoLetto = tastiera.readLine();
  34.                     voto = Integer.valueOf(votoLetto).intValue();
  35.                 }
  36.                 catch(Exception e){
  37.                     System.out.println("Questo non e' un voto");
  38.                     i--;
  39.                     continue;
  40.                 }
  41.                 if (voto < 6){
  42.                     System.out.println("NEGATIVO");
  43.                 }  
  44.                 else if (voto == 6){
  45.                     System.out.println("SUFFICIENTE");
  46.                 }
  47.                 else{
  48.                     System.out.println("POSITIVO");
  49.                 }
  50.             }
  51.         }
  52.         catch(Exception e){
  53.                 System.out.println("Questo non e' un voto");
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement