Question

Instructions Deliverables: (1) A single Java program and (2) A Word document containing a Test Plan/Matrix...

Instructions Deliverables: (1) A single Java program and (2) A Word document containing a Test Plan/Matrix with a set of screen shots that display the output from each of the test plan scenarios appropriately tagged. The Java program file attached to the appropriate Assignment tab must end in either .java or .txt. No zip files, ever. The preferred naming convention for this project is CMIS242PRJ1SmithX, that is the name of the assignment (PRJ1) with your last name (Smith as example), and first initial (X). The Test Plan/Matrix file attached to the appropriate Assignment tab is expected to be in Microsoft Word, but .pdf files are accepted. The preferable naming convention for the test plan is CMIS242PRJ1TestSmithX. The single Java program contains all the classes designed in the assignment. It is expected that prior to the main () element of the program probably named with public class CMIS242PRJ1SmithX in the cmis242.prj1smithx package, you will insert the class Employee, class Salesman, and class Executive. The additional methods expected are for reading a file and assigning to arrays, as well as one to display the output. It is expected that the main () element of the program will be at the end of the source code.

Text file contents:

2014, Employee, Smith, John, 2000,0
2015, Salesman, Jones, Bill, 3000,100000
2014, Executive, Bush, George, 5000,55
2015, Employee, Brevis, Philomenia, 2055,0
2014, Employee, Fall, Beatrice, 1870,0
2015, Executive, Washington, Clarie, 4050,45
2015, Employee, Poole, Albert, 2150, 0
2014, Employee, Able, Paul, 2120, 0
2015, Salesman, Naismith, Frederick, 2100, 90000
2015, Employee, Zane, Xavier, 30100, 0
2014, Salesman, Caldwell, Millicent, 2800, 120000
2015, Employee, Peters, Clovis, 1800, 0
2014, Employee, Syung, Susan, 1800, 0
2015, Employee, Jones, Redding, 2090, 0
2014, Salesman, Jones, Bill, 3000, 100000
2014, Employee, Marshall, Horace, 2300, 0
2015, Executive, Tinker, Willieam, 5590, 59

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________

// data.txt

2014, Employee, Smith, John, 2000,0
2015, Salesman, Jones, Bill, 3000,100000
2014, Executive, Bush, George, 5000,55
2015, Employee, Brevis, Philomenia, 2055,0
2014, Employee, Fall, Beatrice, 1870,0
2015, Executive, Washington, Clarie, 4050,45
2015, Employee, Poole, Albert, 2150, 0
2014, Employee, Able, Paul, 2120, 0
2015, Salesman, Naismith, Frederick, 2100, 90000
2015, Employee, Zane, Xavier, 30100, 0
2014, Salesman, Caldwell, Millicent, 2800, 120000
2015, Employee, Peters, Clovis, 1800, 0
2014, Employee, Syung, Susan, 1800, 0
2015, Employee, Jones, Redding, 2090, 0
2014, Salesman, Jones, Bill, 3000, 100000
2014, Employee, Marshall, Horace, 2300, 0
2015, Executive, Tinker, Willieam, 5590, 59

____________________________

// cmis242.prj1smithx.CMIS242PRJ1SmithX.java

package cmis242.prj1smithx;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class CMIS242PRJ1SmithX {
   public class Employee {
       private int year;
       private String name;
       private double monthlySalary;

       public Employee(int year,String name, double monthlySalary) {
          
           this.year=year;
           this.name = name;
           this.monthlySalary = monthlySalary;
       }

       public double getMonthlySalary() {
           return monthlySalary;
       }

       public String getName() {
           return name;
       }

       public double annualSalary() {
           return monthlySalary * 12;
       }
      

       public int getYear() {
           return year;
       }

       @Override
       public String toString() {
           return "Employee::Year :"+getYear()+" Name=" + name + ", MonthlySalary=" + monthlySalary;
       }

   }

   public class Salesman extends Employee {
       private double annualSales;

       public Salesman(int year,String name, double monthlySalary, double annualSales) {
           super(year,name, monthlySalary);
           this.annualSales = annualSales;
       }

       @Override
       public double annualSalary() {
           return getMonthlySalary() * 12 + (2.0 / 100) * annualSales;
       }

       @Override
       public String toString() {
           return "Salesman::Year :"+getYear()+" Name :" + getName() + " , Monthly Salary :$"
                   + (annualSalary()/12)+" Annual Sales :$"+annualSales;
       }

   }
  
   public class Executive extends Employee
   {
       private double stockPrice;

       public Executive(int year,String name, double monthlySalary, double stockPrice) {
           super(year,name, monthlySalary);
           this.stockPrice = stockPrice;
       }
      
       @Override
       public double annualSalary() {
           double sal=0;
           if(stockPrice>50)
           {
               sal=30000+getMonthlySalary();
           }
           else
           {
               sal=getMonthlySalary();
           }
           return sal;
       }
       @Override
       public String toString() {
           return "Executive:: Year :"+getYear()+" Name :" + getName() + " , Monthly Salary :$"
                   + (annualSalary()/12)+" Stock Price :$"+stockPrice;
       }
      
   }
  
   public static void main(String args[])
   {
   Employee emps[]=readFile();
   display(emps);
   }

   private static void display(Employee emps[]) {
       for(int i=0;i<emps.length;i++)
       {
           System.out.println(emps[i]);
       }
      
   }

   private static Employee[] readFile() {
       int cnt=0;
       Employee emp=null;
       Salesman sm=null;
       Executive exe=null;
       Employee emps[]=null;
       try {
           Scanner readFile=new Scanner(new File("data.txt"));
           while(readFile.hasNext())
           {
               String str=readFile.nextLine();
               cnt++;
           }
           readFile.close();
          
       emps=new Employee[cnt];
           readFile=new Scanner(new File("data.txt"));
           for(int i=0;i<cnt;i++)
           {
               String line=readFile.nextLine();
          
               String arr[]=line.split(",");

               int year=Integer.parseInt(arr[0]);
               String empType=arr[1].trim();
               String fname=arr[2].trim();
               String lname=arr[3].trim();
               String name=fname+" "+lname;

               if(empType.charAt(0)=='E')
               {
                   double monthlySalary=Double.parseDouble(arr[4].trim());
               emps[i]=new CMIS242PRJ1SmithX().new Employee(year, name, monthlySalary);
               }
               else if(empType.charAt(0)=='S')
               {
                   double monthlySalary=Double.parseDouble(arr[4].trim());
                   double annualSales=Double.parseDouble(arr[5].trim());
               emps[i]=new CMIS242PRJ1SmithX().new Salesman(year, name, monthlySalary,annualSales);
               }
               else if(empType.charAt(0)=='E')
               {
                   double monthlySalary=Double.parseDouble(arr[4].trim());
                   double shareCost=Double.parseDouble(arr[5].trim());
               emps[i]=new CMIS242PRJ1SmithX().new Executive(year, name, monthlySalary,shareCost);
               }
                  
              
           }
          
          
           readFile.close();
       } catch (FileNotFoundException e) {
          
           e.printStackTrace();
       }
      
       return emps;
   }
}

_____________________________

Output:

Employee::Year :2014 Name=Smith John, MonthlySalary=2000.0
Salesman::Year :2015 Name :Jones Bill , Monthly Salary :$3166.6666666666665 Annual Sales :$100000.0
Employee::Year :2014 Name=Bush George, MonthlySalary=5000.0
Employee::Year :2015 Name=Brevis Philomenia, MonthlySalary=2055.0
Employee::Year :2014 Name=Fall Beatrice, MonthlySalary=1870.0
Employee::Year :2015 Name=Washington Clarie, MonthlySalary=4050.0
Employee::Year :2015 Name=Poole Albert, MonthlySalary=2150.0
Employee::Year :2014 Name=Able Paul, MonthlySalary=2120.0
Salesman::Year :2015 Name :Naismith Frederick , Monthly Salary :$2250.0 Annual Sales :$90000.0
Employee::Year :2015 Name=Zane Xavier, MonthlySalary=30100.0
Salesman::Year :2014 Name :Caldwell Millicent , Monthly Salary :$3000.0 Annual Sales :$120000.0
Employee::Year :2015 Name=Peters Clovis, MonthlySalary=1800.0
Employee::Year :2014 Name=Syung Susan, MonthlySalary=1800.0
Employee::Year :2015 Name=Jones Redding, MonthlySalary=2090.0
Salesman::Year :2014 Name :Jones Bill , Monthly Salary :$3166.6666666666665 Annual Sales :$100000.0
Employee::Year :2014 Name=Marshall Horace, MonthlySalary=2300.0
Employee::Year :2015 Name=Tinker Willieam, MonthlySalary=5590.0

_______________Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
Instructions Deliverables: (1) A single Java program and (2) A Word document containing a Test Plan/Matrix...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I really need help with this, please. This is a java programming assignment. Project 1 The first programming project inv...

    I really need help with this, please. This is a java programming assignment. Project 1 The first programming project involves writing a program that computes the salaries for a collection of employees of different types. This program consists of four classes. 1. The first class is the Employee class, which contains the employee's name and monthly salary, which is specified in whole dollars. It should have three methods: a. A constructor that allows the name and monthly salary to be...

  • Need help with java programming. Here is what I need to do: Write a Java program...

    Need help with java programming. Here is what I need to do: Write a Java program that could help test programs that use text files. Your program will copy an input file to standard output, but whenever it sees a “$integer”, will replace that variable by a corresponding value in a 2ndfile, which will be called the “variable value file”. The requirements for the assignment: 1.     The input and variable value file are both text files that will be specified in...

  • Assignment on Java programing 1. Write programs for the following exercises in Java. Each file should...

    Assignment on Java programing 1. Write programs for the following exercises in Java. Each file should have short description of the implemented class and for files with main method the problem it is solving. Make sure your files have appropriate names. Programs should write output to the Console. b) BST: Implement Binary Search Tree ADT with insert(int key), delete(int key), Node find(int key), and in-order traverse() where it prints the value of the key. Your operations should use recursion. The...

  • Description: This Java program will read in data from a file students.txt that keeps records of...

    Description: This Java program will read in data from a file students.txt that keeps records of some students. Each line in students.txt contains information about one student, including his/her firstname, lastname, gender, major, enrollmentyear and whether he/she is a full-time or part-time student in the following format. FIRSTNAME      LASTNAME        GENDER              MAJORENROLLMENTYEAR FULL/PART The above six fields are separated by a tab key. A user can input a keyword indicating what group of students he is searching for. For example, if...

  • Instructions ASSIGNMENT 2 is at bottom of the question. Very simple program and these intructions are...

    Instructions ASSIGNMENT 2 is at bottom of the question. Very simple program and these intructions are only to modify it slightly, should only take about 10 minutes says my proffessor. Your file should be named “Main.java”. Ask the user how many year inputs he wants to check - an integer. Assume that the user always gives an input which is between 1 and 5 (inclusive). Next, ask the user for K number of year inputs where K = the number...

  • JAVA PROGRAM USING ECLIPSE. THE FIRST IMAGE IS THE INSTRUCTIONS, THE SECOND IS THE OUTPUT TEST...

    JAVA PROGRAM USING ECLIPSE. THE FIRST IMAGE IS THE INSTRUCTIONS, THE SECOND IS THE OUTPUT TEST CASES(WHAT IM TRYING TO PRODUCE) BELOW THOSE IMAGES ARE THE .JAVA FILES THAT I HAVE CREATED. THESE ARE GeometircObject.Java,Point.java, and Tester.Java. I just need help making the Rectangle.java and Rectangle2D.java classes. GeometricObject.Java: public abstract class GeometricObject { private String color = "white"; // shape color private boolean filled; // fill status protected GeometricObject() { // POST: default shape is unfilled blue this.color = "blue";...

  • Exercise 1: Adding a Test Harness to the Person class To make it easier to test...

    Exercise 1: Adding a Test Harness to the Person class To make it easier to test code that you have written for a Java class you can add to that class a main method that acts as a "test harness". A test harness is a main method that includes calls to methods that you wish to test. For convention this main method is the last method of the class. If you have a test harness, you do not need to...

  • Question 2: Levenshtein Take the recursive Java program Levenshtein.java and convert it to the equivalent C...

    Question 2: Levenshtein Take the recursive Java program Levenshtein.java and convert it to the equivalent C program. Tip: You have explicit permission to copy/paste the main method for this question, replacing instances of System.out.println with printf, where appropriate. Notes You can get the assert function from assert.h. Try running the Java program on the CS macOS machines. You can compile and run the program following the instructions provided in assignment 0. Assertions are disabled by default. You can enable assertions...

  • Java Project For this assignment, you will write a simulation program to determine the average waiting...

    Java Project For this assignment, you will write a simulation program to determine the average waiting time at a grocery store checkout while varying the number of customers and the number of checkout lanes. Classes needed: SortedLinked List: Implement a generic sorted singly-linked list which contains all of the elements included in the unsorted linked list developed in class, but modifies it in the following way: delete the addfirst, addlast, and add(index) methods and instead include a single add method...

  • Needs Help with Java programming language For this assignment, you need to write a simulation program...

    Needs Help with Java programming language For this assignment, you need to write a simulation program to determine the average waiting time at a grocery store checkout while varying the number of customers and the number of checkout lanes. Classes needed: SortedLinked List: Implement a generic sorted singly-linked list which contains all of the elements included in the unsorted linked list developed in class, but modifies it in the following way: • delete the addfirst, addlast, and add(index) methods and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT