I am trying to create a sort of pay slip to print in the console but I receive the following errors from my code. Its really just one error many times, but I don't think I have enough knowledge of java to fix it on my own.
import java.io.*;
import java.text.*;
import java.util.Scanner;
class Assign2num2
{
public static void main (String [] args)
{
String famname, firstname;
double gross, deduct, tax, pay, hrs, ovtm;
char letter, yn;
Scanner in = new Scanner(System.in);
System.out.println("Please enter your family name and first name.");
famname = in.nextLine();
firstname = in.nextLine();
System.out.println("Please enter how much you are paid per hour and the amount of hours you worked this week. Enter overtime hours seperately please.");
pay = in.nextInt();
if (pay<0) {
System.out.println("You must enter a positive number or zero for your hourly pay.");
pay = in.nextInt();
}
else {
pay = pay;
}
hrs = in.nextInt();
if (hrs<0||hrs>40) {
System.out.println("You must enter a positive number less than or equal to 40, or zero for the amount of hours worked this week.");
hrs = in.nextInt();
}
else {
hrs = hrs;
}
ovtm = in.nextInt();
if (ovtm<0) {
System.out.println("You must enter a positive number or zero for your overtime hours worked.");
ovtm = in.nextInt();
}
else {
ovtm = ovtm;
}
gross = (pay*hrs) + ((pay*2)*ovtm);
System.out.println("Please enter a letter indicating your tax category: A is no tax deduction, B is 10% of gross pay, \nC is 20% of gross pay, D is 29% of gross pay, E is 35% of gross pay");
letter = in.next().charAt(0);
if (letter==A||letter==a){
letter = letter;
gross = gross;
}
else if (letter==B||letter==b){
letter = letter;
deduct = (gross*0.1);
tax = gross - deduct;
}
else if (letter==C||letter==c){
letter = letter;
deduct = (gross*0.2);
tax = gross - deduct;
}
else if (letter==D||letter==d){
letter = letter;
deduct = (gross*0.29);
tax = gross - deduct;
}
else if (letter==E||letter==e){
letter = letter;
deduct = (gross*0.35);
tax = gross - deduct;
}
else {
System.out.println("You must enter a letter between A and E.");
letter = in.next().charAt(0);
}
System.out.println("If you want $20.00 deducted from your weekly pay as a contribution to the \nUnited Way Charity, enter Y for yes. If not, enter N for no.");
yn = in.next().charAt(0);
if (letter==Y||letter==y||letter==N||letter==n){
yn = yn;
}
else {
System.out.println("You must enter either Y or N.");
yn = in.next().charAt(0);
}
if (yn==Y||yn==y) {
deduct = deduct + 20;
tax = tax - 20;
}
else {
deduct = deduct;
tax = tax;
System.out.println("PAY SLIP");
System.out.println("---------");
System.out.println(famname + ", " + firstname);
System.out.println("---------");
System.out.println("Gross Pay: " + gross);
System.out.println("---------");
System.out.println("Deductions: " + deduct);
System.out.println("---------");
System.out.println("Net Pay: " + tax);
}
}
}
16 errors found:
File: G:\Computer Science\Dr Java Exercises\Java Files\Assign2num2.java [line: 44]
Error: cannot find symbol
symbol: variable A
location: class Assign2num2
File: G:\Computer Science\Dr Java Exercises\Java Files\Assign2num2.java [line: 44]
Error: cannot find symbol
symbol: variable a
location: class Assign2num2
File: G:\Computer Science\Dr Java Exercises\Java Files\Assign2num2.java [line: 48]
Error: cannot find symbol
symbol: variable B
location: class Assign2num2
File: G:\Computer Science\Dr Java Exercises\Java Files\Assign2num2.java [line: 48]
Error: cannot find symbol
symbol: variable b
location: class Assign2num2
File: G:\Computer Science\Dr Java Exercises\Java Files\Assign2num2.java [line: 53]
Error: cannot find symbol
symbol: variable C
location: class Assign2num2
File: G:\Computer Science\Dr Java Exercises\Java Files\Assign2num2.java [line: 53]
Error: cannot find symbol
symbol: variable c
location: class Assign2num2
File: G:\Computer Science\Dr Java Exercises\Java Files\Assign2num2.java [line: 58]
Error: cannot find symbol
symbol: variable D
location: class Assign2num2
File: G:\Computer Science\Dr Java Exercises\Java Files\Assign2num2.java [line: 58]
Error: cannot find symbol
symbol: variable d
location: class Assign2num2
File: G:\Computer Science\Dr Java Exercises\Java Files\Assign2num2.java [line: 63]
Error: cannot find symbol
symbol: variable E
location: class Assign2num2
File: G:\Computer Science\Dr Java Exercises\Java Files\Assign2num2.java [line: 63]
Error: cannot find symbol
symbol: variable e
location: class Assign2num2
File: G:\Computer Science\Dr Java Exercises\Java Files\Assign2num2.java [line: 75]
Error: cannot find symbol
symbol: variable Y
location: class Assign2num2
File: G:\Computer Science\Dr Java Exercises\Java Files\Assign2num2.java [line: 75]
Error: cannot find symbol
symbol: variable y
location: class Assign2num2
File: G:\Computer Science\Dr Java Exercises\Java Files\Assign2num2.java [line: 75]
Error: cannot find symbol
symbol: variable N
location: class Assign2num2
File: G:\Computer Science\Dr Java Exercises\Java Files\Assign2num2.java [line: 75]
Error: cannot find symbol
symbol: variable n
location: class Assign2num2
File: G:\Computer Science\Dr Java Exercises\Java Files\Assign2num2.java [line: 82]
Error: cannot find symbol
symbol: variable Y
location: class Assign2num2
File: G:\Computer Science\Dr Java Exercises\Java Files\Assign2num2.java [line: 82]
Error: cannot find symbol
symbol: variable y
location: class Assign2num2