0

program to repeat again and again with while but its now working

// ERROR IS IN WHILE(1) IT SAYS CANT CONVERT FROM INT TO BOOLEAN import java.util.Scanner; public class Student { public static Student kreiraj (final Scanner s) { String ime=s.next(); //pozivanje konstruktora String prezime=s.next(); //preko Scanner return new Student(); } static int i; static int[] niz=new int[5]; static int total() { int total=0; for(i=0;i<niz.length;i++) { total+=niz[i]; } return total; } static int avg() { int avg=total()/niz.length; return avg; } public static void main(String[] args) { while(1) { Scanner s=new Scanner(System.in); System.out.println("Give ime i prezime"); Student x = Student.kreiraj(s); //pozivanje u main System.out.println("put elements"); for(i=0;i<5;i++) { niz[i]=s.nextInt(); } System.out.println("ocene su"); for(i=0;i<5;i++) { System.out.println(niz[i]); } System.out.println("a zbir je"+total()); System.out.println("sto znaci da je avg"+avg()); } }} // ERROR IS IN WHILE(1) IT SAYS CANT CONVERT FROM INT TO BOOLEAN

3rd Apr 2020, 3:58 PM
Dzondzula
Dzondzula - avatar
1 Answer