Take a look at Line 23 where you declare the int variable vacation. This variable is declared within the body of a conditional statement, which means its lifespan is confined to that conditional block. Nothing outside of that block can see that variable. Take a look at the changes I have made:
import java.util.*;
public class MainClass
{
public static void main(String[] args) //need to declare a parameter //that is a String array
{
System.out.println("Enter the employee type (Professional or Hourly)");
Scanner scan = new Scanner(System.in);
String type = scan.nextLine();
type = type.toUpperCase();
int vacation = 0; // declare int in main method
System.out.println("Enter the employee's name");
String name = scan.nextLine();
System.out.println("Enter the employee's ID Number (int)");
int idNumber = scan.nextInt();
System.out.println("Enter the employee's pay (double)");
double pay = scan.nextDouble();
if (type.equals("PROFESSIONAL"))
{
System.out.println("Enter the employee's accrued vacation (int)");
vacation = scan.nextInt();
}
else
{
// Pay person1 = new Pay(name, idNumber, pay);
}
System.out.format("%s is id %d with pay $%.2f %d%n", name, idNumber, pay, vacation);
}
} I hope this helps. I also fixed your main method declaration. Take a look here for more information on variables & scope: here
majestic0110
Nearly a Posting Virtuoso
1,328 posts since Oct 2007
Reputation Points: 256
Solved Threads: 72