Hey everyone! I'm taking my very first java class and having a few issues. We are supposed to create a program that creates a text file and one that searches through it. I finished the creating one but having some issues on the one that searches. I'm supposed to search through the first and last name strings to see if that name is in the string then print the salary for the person if it is. I keep getting incompatible types errors. Here's the code so far:
Also, like I said, this is only my first java class so please try to make suggestions easy to understand.
Thanks!
-Lacey
import java.io.File; import java.util.Scanner; public class ReadTextFile { public static void main( String[] args ) throws Exception { Scanner input = new Scanner( new File( "company.txt" ) ); int accountNumber; String firstName; String lastName; double salary; double wage; double hours; System.out.println("Enter first and last name"); int f = input.nextInt(); int l = input.nextInt(); if(firstName.equals(f)&&lastName.equals(l)) System.out.printf("salary: %d", salary); else System.out.println("Sorry could not find person"); } }
Also, like I said, this is only my first java class so please try to make suggestions easy to understand.
Thanks!
-Lacey