The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 305 Weeks Ago, 1 Day Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Hello,
Â
I have done all the work but cannot produce screenshots. public class Employee {
   private String name;
   private int monthlySalary;
  Â
  Â
   public Employee(String name, int monthlySalary) {
      super();
      this.name = name;
      this.monthlySalary = monthlySalary;
   }
  Â
  Â
   public int annualSalary() {
      return monthlySalary*12;
   }
   @Override
   public String toString() {
      return "name=" + name + ", monthlySalary=" + monthlySalary;
   }
  Â
}
Can you help? Another tutor was also stumped.public class Executive extends Employee {
   private int stockPrice;
   public Executive(String name, int monthlySalary , int stockPrice) {
      super(name, monthlySalary);
      this.stockPrice = stockPrice;
   }
   @Override
   public int annualSalary() {
      int bonus = 30000;
      if (stockPrice > 50) {
         return super.annualSalary() + bonus;
      } else {
         return super.annualSalary();
      }
   }
   @Override
   public String toString() {
      return super.toString() + " stockPrice=" + stockPrice;
   }
  Â
  Â
  Â
  Â
}import java.io.File;
import java.util.Scanner;
public class MainDriver {
   public static void main(String[] args) {
      Employee[] employee2014 = new Employee[10];
      Employee[] employee2015 = new Employee[10];
      int index2014 =0;
      int index2015 =0;
      try {
         File file = new File("data.txt");
         Scanner input = new Scanner(file);
         while (input.hasNextLine()) {
            String line = input.nextLine();
            String [] strSplit = line.split(" ");
            Employee e =null;
            if("Employee".equals(strSplit[1])) {
               e = new Employee(strSplit[2], Integer.valueOf(strSplit[3]));
            } else if("Salesman".equals(strSplit[1])) {
               e = new Salesman(strSplit[2], Integer.valueOf(strSplit[3]) , Integer.valueOf(strSplit[4]));
            } else if("Executive".equals(strSplit[1])) {
               e = new Executive(strSplit[2], Integer.valueOf(strSplit[3]) , Integer.valueOf(strSplit[4]));
            }
            if("2014".equals(strSplit[0])) {
               employee2014[index2014++] = e;
            } else {
               employee2015[index2015++] = e;
            }
         }
         input.close();
        Â
         //2014 report
         int totalSalary = 0;
         for(int i=0 ; i < index2014 ; i++) {
            System.out.println(employee2014[i].toString());
            int annualSalary = employee2014[i].annualSalary();
            System.out.println("Annual Salary :" + annualSalary);
            totalSalary = totalSalary + annualSalary;
         }
        Â
         System.out.println("The average Salary for Employees in 2014 is : " + totalSalary/(index2014));
         System.out.println();
        Â
         //2015 report
         totalSalary = 0;
         for(int i=0 ; i < index2015 ; i++) {
            System.out.println(employee2015[i].toString());
            int annualSalary = employee2015[i].annualSalary();
            System.out.println("Annual Salary :" + annualSalary);
            totalSalary = totalSalary + annualSalary;
         }
        Â
         System.out.println("The average Salary for Employees in 2015 is : " + totalSalary/(index2015));
      } catch (Exception ex) {
         ex.printStackTrace();
      }
   }
}
public class Salesman extends Employee {
   private int annualSales;
   public Salesman(String name, int monthlySalary , int annualSales) {
      super(name, monthlySalary);
      this.annualSales = annualSales;
   }
   @Override
   public int annualSalary() {
      int commision = annualSales * 2 / 100;
      if (commision > 20000) {
         return super.annualSalary() + 20000;
      } else {
         return super.annualSalary() + commision;
      }
   }
   @Override
   public String toString() {
      return super.toString() + " annualSales=" + annualSales;
   }
}
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly