I am completely stuck. I am designing a CommissionCalculator class that prints a menu and asks a user for input in order to calculate commission on Auto, Home, and Life insurance policies. I have written the Auto, Home, and Life classes and began the CommissionCalculator class. Here is a copy of the assignment specs and what is required:
"Design and implement a CommissionCalculator class that has a single Auto, Home, and Life insurance policy object from the classes developed in the previous lab. Create each object in the CommissionCalculator constructor and write a method named Run that prompts the user for information and computes commission and prints each policy using the menu below. Write a driver class that simply creates and runs a CommissionCalculator object.
-----------------------------
Welcome to Parkland Insurance
-----------------------------
Enter any of the following:
1) Enter auto insurance policy information
2) Enter home insurance policy information
3) Enter life insurance policy information
4) Compute commission and print auto policy
5) Compute commission and print home policy
6) Compute commission and print life policy
7) Quit "
I am stuck on the Run method completely. I need to know how to get the user input with I am assuming the scanner object and I don't know the proper syntax or how to get multiple inputs from the same line. Below is what I have so far. I know that the Run method looks like a mess. I just need some help on how I can write the method and get all the input I need. Do I need to use a switch, loop, array list or something else? I believe the constructor, getters, and setters are correct but I am not 100% sure. Any help would be greatly appreciated...
I can upload an attachment if necessary if you need to see the other classes I created. I know this has something to do with aggregation or inheritance.
import java.util.Scanner;
public class CommissionCalculator
{
//what the class knows
private Auto auto;
private Home home;
private Life life;
//what the class does
//constructor
public CommissionCalculator()
{
//create the class objects
auto = new Auto();
home = new Home();
life = new Life();
}
// run method
public double Run()
{
System.out.println("----------------------------");
System.out.println("Welcom to Parkland Insurance");
System.out.println("----------------------------");
System.out.println("Enter any of the following: ");
Scanner myObj = new Scanner(System.in);
System.out.println("1) Enter auto insurance policy information");
double cc = scan.nextDouble();
double liability = myObj.nextDouble();
double collision = myObj.nextDouble();
double commissionAuto = ((liability + collision)*.30);
return commissionAuto;
}
public Auto getAuto() {
return auto;
}
public void setAuto(Auto auto) {
this.auto = auto;
}
public Home getHome() {
return home;
}
public void setHome(Home home) {
this.home = home;
}
public Life getLife() {
return life;
}
public void setLife(Life life) {
this.life = life;
}
// toString
public String toString() {
return "CommissionCalculator [auto=" + auto + ", home=" + home + ", life=" + life + "]";
}
}