Hello, I am new to Java and I've got a problem already.
The program should copy person with the highest percent from the file 'plik1', and then put it to the file 'plik2'.
The problem occurs while compiling.
Thank you for understanding and your help,
fkmk
Compilator:
string cannot be resolved to a type string cannot be resolved to a type string cannot be resolved to a type string cannot be resolved to a type string cannot be resolved to a type string cannot be resolved to a type string cannot be resolved to a type string cannot be resolved to a type
Code:
package zadanie2; import java.util.*; import java.io.*; public class zadanie2 { public static void main(String[] args) throws Exception { Scanner plik1 = new Scanner(new File("plik.txt")); plik1.useLocale(Locale.US); PrintWriter plik2 = new PrintWriter("plik_max.txt"); Person person[] = new Person[5]; System.out.println("List of people:"); while(plik1.hasNext()) { for(int counter=0; counter<5; counter++) { person[counter].name = plik1.next(); person[counter].surname = plik1.next(); person[counter].age = plik1.nextInt(); person[counter].percent = plik1.nextFloat(); System.out.println("%s %s %d %f", person[counter].name, person[counter].surname, person[counter].age, person[counter].percent); counter++; } int counter = 0; float maximum = person[0].percent; for(counter=1; counter<5; counter++) { if(person[counter].percent > maximum) maximum = person[counter].percent; } char badge = '*'; for(counter=0; counter<5; counter++) { if((person[counter].name.length() > 3) && (person[counter].surname.lastIndexOf("ski")) && (person[counter].percent == maximum)) { plik2.print(person[counter].name); plik2.print(person[counter].surname); plik2.println(person[counter].age); } } } plik1.close(); plik2.close(); } } class Person { public : string name; string surname; int age; float percent; }