Fix and delate nextLine()

This commit is contained in:
Orange_Dugongo 2016-10-21 14:41:53 +02:00
parent 3f0a55026c
commit a8e5494aa0
6 changed files with 10 additions and 9 deletions

Binary file not shown.

View File

@ -30,8 +30,8 @@ public class Esame{
String nome;
int voto;
int mat;
if(sc.hasNextLine()){
nome=sc.nextLine();
if(sc.hasNext()){
nome=sc.next();
if(sc.hasNextInt()){
voto=sc.nextInt();
if(sc.hasNextInt()){

Binary file not shown.

View File

@ -24,9 +24,7 @@ public class Main{
sc=new Scanner(srcEsami);
e=Esame.read(sc);
while(e!=null){
System.out.println(e.getVoto()+" "+e.getMat()+" "+e.getNome());
if(e.lookUp(s.getMat())){
System.out.println("ok "+e.getVoto());
media+=e.getVoto();
i++;
}
@ -37,6 +35,9 @@ public class Main{
s=Studente.read(sc);
}
if(s!=null)
System.out.println("lo studente "+s.getNomeCognome()+" ha la media di: "+media/i);
else
System.out.println("Impossibile trovare delle corrispondenze.");
}
}

Binary file not shown.

View File

@ -26,10 +26,10 @@ public class Studente{
String nome;
String cnome;
int mat;
if(sc.hasNextLine()){
nome=sc.nextLine();
if(sc.hasNextLine()){
cnome=sc.nextLine();
if(sc.hasNext()){
nome=sc.next();
if(sc.hasNext()){
cnome=sc.next();
if(sc.hasNextInt()){
mat=sc.nextInt();
return new Studente(nome, cnome, mat);