If you can't read please download the document
Upload
reggies-oluoch
View
214
Download
0
Embed Size (px)
DESCRIPTION
Template for system design and implementation
Citation preview
public class Employee {
private int jobgrade; private double salary;
public int getJobGrade() { return jobgrade; }
public void setJobGrade(int jg) { jobgrade = jg; }
public double testJob() { if (jobgrade == 1) { salary = 10000; } else if (jobgrade == 2) { salary = 20000; } else if (jobgrade == 3) { salary = 30000; } else if (jobgrade == 4) { salary = 40000; } return salary; }
}
import java.util.Scanner;import java.util.InputMismatchException;
public class EmployeeMain {
public static void main(String[] args) { try { display(); } catch (InputMismatchException e) { System.out.println("Job grade must be numeric"); } catch (ExceedException ee) { System.out.println(ee.getMessage()); } }
public static void display() throws InputMismatchException, ExceedException { Scanner scan = new Scanner(System.in);
System.out.println("Input job grade number 1 - 4 to determine salary");
int jg = scan.nextInt(); if (jg < 0 || jg > 4) { throw new ExceedException("Job Grade cannot be less than 1 or more than 4"); } Employee emp = new Employee(); emp.setJobGrade(jg); System.out.println("Your job grade is: " + jg + " and salary is: " + emp.testJob());
}
}