
” CS526 O2课程编程 写作、Java程序设计 辅导CS526 O2 Fall 2020Homework Assignment 1This assignment is practice of Java basics.Problem 1 (50 points). An incomplete Java program named Hw1_P1_incomplete.java is postedon the course website. You must complete the program by implementing the followingrequirements. Dont forget to delete _incomplete from the file name.This program has three methods. The first method receives an array of integers and calculates theaverage, the minimum, And the maximum of the integers and prints them on the screen.The signature of this method is:public static void stats(int[ ] numbers)The second method creates and prints a subarray of a given array. The specification of the methodis: Signature of method:public static void subarray(int[ ] a, int from, int to) Input arguments:a: An array of integersfrom: The index of an element in a which becomes the first element in the subarrayto: The index of an element in a which becomes the last element in the subarray Behavior: A new integer array is created, which is a subarray of a, and it includes elementsa[from] to a[to], inclusively. Prints the subarray. There is no return value.The third method is a main method. If you run this program with the following main method:public static void main(String[] args) {int[] a = {15, 25, 10, 65, 30, 55, 65}; System.out.print(\nGiven array is: ); for (int i=0; ia.length‐1; i++) { System.out.print(a[i] + , ); } System.out.print(a[a.length ‐ 1]); System.out.println(); stats(a); subarray(a, 1, 4);Your output should be:Given array is: 15, 25, 10, 65, 30, 55, 65average = 37.86, min = 10, max = 65The subarray, From index 1 to index 4, is: 25, 10, 65, 30Problem 2 (50 points). For this problem, first you need to write a subclass of the Employeeclass. The definition of the Employee class is in the Employee.java file and it is briefly describedbelow:Class EmployeeInstance variables empId: Description: Employee id of an employee Type: integer name: Description: Name of an employee Type: StringInstance methods: getEmpId No input argument Returns the employee id getName No input argument Returns the employee name setEmpId Input argument: EmpId of integer type Existing empId is replaced with the given empId No return value setName Input argument: name of String type Existing name (which may be null) is replaced with the given name No return valueYou need to implement the following class, which is a subclass of the Employee class. Definethis class in a separate file named SalariedEmployee.java.Class SalariedEmployee A subclass of the Employee class Instance variables salary: annual salary; double type Instance method monthlyPayment No input argument Returns monthly payment; double type Monthly payment is calculated as salary / 12 employeeInfo No input argument Displays the empId, name, salary, and monthly payment No return valueIn the subclass definition, you must implement all necessary get methods and set methods.Then, write a program, named Hw1_P2.java, that reads employee information from a text fileand stores SalariedEmployee objects in an array of size 10, named employeeArray, and displaysemployees satisfying a certain criterion. Follow the instruction below: Write a method, Named employeesAbove, whose behavior is specified below: Signature of method:public static void employeesAbove (SalariedEmployee[ ] empArray, doublethreshold) Input arguments:empArray: An array of SalariedEmployee objectsthreshold: A salary threshold Behavior: Selects from empArray only those employees who earn more than thegiven threshold amount, and displays their empId, name, salary, and monthlypayment. There is no return value. In the main method, do the following: Read information of 10 salaried employees from an input file namedemployee_input.txt And create 10 SalariedEmployee objects and store them inemployeeArray. A sample input file is shown below:1, John, 500002, Susan, 1200003, Yapsiong, 800004, Gomez, 900005, Minsky, 600006, Yorst, 300007, Govindranad, 400008, Kelsey, 600009, Jake, 11000010, Guanyu, 70000 Invoke the employeesAbove method a few times with different threshold values andcheck that your output is correct. If, for example, you invoke the method with thethreshold 70000, then the output should be:Employees earning more than $70000: Employee id = 2Name = SusanSalary = 120000.00Monthly pay = 10000.00Employee id = 3Name = YapsiongSalary = 80000.00Monthly pay = 6666.67Employee id = 4Name = GomezSalary = 90000.00Monthly pay = 7500.00Employee id = 9Name = JakeSalary = 110000.00Monthly pay = 9166.67DeliverableNo separate documentation is needed for the program files. However, you must include thefollowing in your source code: Include the following comments above each method: Brief description of the method Input arguments Output arguments Include inline Comments within your source code to increase readability of your code andto help readers better understand your code.You must submit the following files: Hw1_P1.java SalariedEmployee.java Hw1_P2.javaCombine all files into a single archive file and name it LastName_FirstName_hw1.EXT, whereEXT is an appropriate archive file extension, such as zip or rar.GradingProblem 1: If your Hw1_P1.java program does not compile, 30 points are deducted. If your program compiles but causes a runtime error, 20 points are deducted. If there is no Output or output is completely wrong, 20 points are deducted. If your output is partly wrong, up to 20 points are deducted.Problem 2: If there is an error in the class definition of SalariedEmployee, up to 10 points arededucted. If your program does not compile, 30 points are deducted. If your program compiles but causes a runtime error, 20 points are deducted. If there is no output or output is completely wrong, 20 points are deducted. If your output is partly wrong, up to 20 points are deducted.如有需要,请加QQ:99515681 或邮箱:99515681@qq.com
“
添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导。






