Question

In: Computer Science

Please provide step by step detailing on how i should do this assignment. In Angel, you...

Please provide step by step detailing on how i should do this assignment. In Angel, you will find a class called Employee. This class should include a constructor which sets name to blanks and salary to $0.00 and a constructor which sets name to a starting name and salary to a set amount. Additionally, the class should include methods to set the name and salary and return the name and salary. Create another method to return the name and salary nicely formatted as a string (hint – research the toString method). You will create a new class called Manager that inherits from the class Employee. Add a field named department of type String. Supply a method toString that prints the manager's name, department, and salary. Remember, you may not change anything in the Employee class. You will then create a test class that uses the Manager class. The test class should prompt the user to enter name, department and salary. This information should be stored in an array. Upon entry of 3 employee records, the program should output the information you entered. Your program should be able to handle a maximum of 3 entries. You may write the program as a console application or using dialog boxes. Also, please provide explanation on how to create each class on java eclipse so that the code can run successfully. Please provide description for everything, I’m a beginner trying to do this assignment.

Solutions

Expert Solution

- Please rename classes as per the requirement.

- In eclipse, goto > File > New > Java Project.
- Give a project name and create Project
- In the project, right click and create a package of your choice.
- In the package, create these classes and then run the class with the main method.
- Its your wish to make seperate files are a single file having all the classes.


Kindly upvote if this helped. Comment for more help

Code:

import java.util.Scanner;

public class TestingManager {
public static void main(String[] args) {
        Scanner sc = new Scanner(System.in); // used to take user input
        double salary;
        String name,dept;
        Manager m[] = new Manager[3]; // initializes for 3 records
        for(int i=1;i<=3;i++) {
                System.out.println("Enter Record for employee number "+i);
                System.out.println("Enter name");
                name = sc.nextLine();
                System.out.println("Enter salary");
                salary = Double.parseDouble(sc.nextLine());
                System.out.println("Enter department");
                dept = sc.nextLine();
                m[i-1] = new Manager(); // creating object
                m[i-1].setDepartment(dept); // setting data to each object record
                m[i-1].setName(name);
                m[i-1].setSalary(salary);
        }
        sc.close();
        
        System.out.println("Information of employees\n");
        
        for(int i=1;i<=3;i++) {
                System.out.println("Record for employee number "+i);
                System.out.println("Name is "+m[i-1].getName());
                System.out.println("Salary is "+m[i-1].getSalary());
                System.out.println("Department is "+m[i-1].getDepartment()+"\n");
        }
        
        
}
}


class Emp{
        String name;   //these are two class variables
        public String getName() { // get name method
                return name;
        }
        public void setName(String name) { // set name method
                this.name = name;
        }
        public double getSalary() {
                return salary;
        }
        public void setSalary(double salary) {
                this.salary = salary;
        }
        double salary;
        Emp(){            // when object of class is created, constructor is invoked first
                name = "";
                salary = 0.00;
        }
        
        public String toString() {
                return "Salary of "+name+" is "+salary; // it will return as "salary of aman is 1111.11";
        }
        
}

class Manager extends Emp{
        String department;

        public String getDepartment() {
                return department;
        }

        public void setDepartment(String department) {
                this.department = department;
        }
        
        public String toString() {
                return "Salary of "+name+" is "+salary+" having department "+department; // as we have inherited, public class variables are accessible in child class directly
        }
        
}


Sample Output





Snapshot for indent


Related Solutions

Please provide step by step on how to create the header files for this project. I...
Please provide step by step on how to create the header files for this project. I received code for it but I am getting an error and I know it has to do with my header files. Please provide instructions on how to create these files along with the full code in C++ for the following: Write a C++ program to simulate a service desk. This service desk should be able to service customers that can have one of three...
Can you tell me the step by step process of how to do this? Provide a...
Can you tell me the step by step process of how to do this? Provide a substantive response that addresses all areas of the item below. Your organization has asked you to estimate the proportion of current employees who expect to retire by the age of 65. Develop an appropriate sampling frame and sampling approach to facilitate this task. Note: Your sample must be random. Outline the data collection process you would employ. Additionally, provide a substantive response to the...
What is normalzing a wavefunction and how do you do it step by step? Please show...
What is normalzing a wavefunction and how do you do it step by step? Please show TWO different examples (one for SHO question, an IPW question, etc) Thanks!
I need step by step instructions on using Excel to do this assignment and the values...
I need step by step instructions on using Excel to do this assignment and the values I need to enter to compute what is being asked of me. I don't know how to use Excel and you tube is no help right now because I can't find specifics of what I need done. I'll post part two of this assignment as a seperate question. I need to get through part one first. Thanks... 1. Exercise 11   Section 3-1 11. Weight...
How do you perform hypothesis testing on multiple regression data from ANOVA table step-by-step? Please provide...
How do you perform hypothesis testing on multiple regression data from ANOVA table step-by-step? Please provide example.
How do I calculate this? Please include detailed step by step method to solve. The Springvale...
How do I calculate this? Please include detailed step by step method to solve. The Springvale Seaside owners see the change in profits from the price decrease in May and the projection for June. They decide to go back to a price of $81.00 and have sales of 35,000 boxes in June. The May production required staff to work 2 weekends and there were many complaints. No one wanted to work weekends during vacation season in Maine and there was...
Write on the Five-Step Marketing Research Approach detailing how you will use each step to solve...
Write on the Five-Step Marketing Research Approach detailing how you will use each step to solve the membership issue the local nonprofit charity is facing. Address the following in your role as marketing manager: Scenario: You are the marketing manager for a local nonprofit charity whose funding is based on membership fees. You've noticed a severe drop in new memberships and a decline in repeat memberships, which is threatening your organization's ability to survive and grow. You have decided to...
And please show me the step by step process of how you solved the question. I...
And please show me the step by step process of how you solved the question. I have a learning disability and I need to know the steps to solve the question If it takes 17.5 mL of 0.085 M NaOH to titrate a 15 mL sample of sauerkraut juice, what is the acidity of that juice, expressed as % lactic acid (wt/vol)?
How can I solve this problem? Can you please show step by step how to solve...
How can I solve this problem? Can you please show step by step how to solve this? Qd = 2,000 − 10P MC = 0.1Q
Could you please give me step-by-step on how to solve this. Thank you! I believe that...
Could you please give me step-by-step on how to solve this. Thank you! I believe that the population proportion for 50% of the people who live in my neighborhood drive a mini van. I surveyed 40 people/houses in my neighborhood and found that only 19 drive mini vans. Use the significance level .10 to test the hypothesis.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT