SO I have an assignment for one of my classes to create an Insurance Calculator that takes in some input for ones age, level of education, marriage status, and employment status and uses this to come up with an insurance payment. The default payment is set to 100 and if an individual is younger than 22 or older than 70, the insurance is increased by 25%. If the individual has a Bachelors, the cost is reduced by 10% (20% for masters), and if the individual is married it is further decreased by 20%. If their employment status is student, cost increases 10%, but if they are unemployed it decreases 5%. I have a huge block of code and Ive been running through it for the last few days and I seem to be stuck on my conditionals. Currently running in two classes, one for the Individual.Class and one for the user inputs.
Individual.java:
public class Individual {
private int age;
private String ed_stat;
private String mar_stat;
private String emp_stat;
private double default_Payment = 100;
public Individual(int suns, String edu, String mar, String employ, double payments) {
this.age = suns;
this.ed_stat = edu;
this.mar_stat = mar;
this.emp_stat = employ;
this.defaultPayment = payments;
}
public int getAge() {
return this.age;
}
public String getEdu() {
return this.ed_stat;
}
public String getMar() {
return this.mar_stat;
}
public String getEmploy() {
return this.emp_stat;
}
public double getPay(){
if (22 < age > 70) {
default_Payment = default_Payment + (default_Payment * .25);
}
if (ed_stat == "Bachelor's") {
default_Payment = default_Payment - (default_Payment * .10);
}
if (ed_stat == "Master's") {
default_Payment = default_Payment - (default_Payment * .20);
}
if (mar_stat == "yes") {
default_Payment = default_Payment - (default_Payment * .20);
}
if (emp_stat == "Student") {
default_Payment = default_Payment + (default_Payment * .10);
}
if (emp_stat == "Unemployed") {
default_Payment = default_Payment - (default_Payment * .05);
}
return this.default_Payment;
}
public void setAge(int suns) {
this.age = suns;
}
public void setEdu(String edu) {
this.ed_stat = edu;
}
public void setMar(String mar) {
this.mar_stat = mar;
}
public void setEmploy(String employ) {
this.emp_stat = employ;
}
public void setPayment(double payments) {
this.default_Payment = payments;
}
public String toString() {
return String("Age: " + age() + ", Education : " + ed_stat + ", Marital Status: " + mar_stat + ", Employment Status: " + emp_stat + ", Payment: " + default_Payment);
}
}
And the InsuranceCalculator.java
import java.util.Scanner;
public class InsuranceCalculator {
public static void main(String[] args) {
double insurance = 100;
Scanner scan = new Scanner(System.in);
System.out.println("Please enter your age: ");
int years = scan.nextInt();
System.out.println("Please enter your education level as High School, Bachelor's, or Master's");
String edu = scan.next();
System.out.println("Are you married? Yes or No");
String mar = scan.next();
System.out.println("Please indicate your employment status as Unemployed, Student, or Employed");
String employ = scan.next();
Individual me = new Individual(years, edu, mar, employ, insurance);
System.out.println(me.toString());
}
Note that I have errors in the Individual.java and I can't tell how the Calculator class will run once I fix the Individual.java.
Any help is greatly appreciated, I will be working on my own as well and will update as I solve