Thursday, May 23, 2019

Prg420 V10 Week 4 Individual Assignment Essay

PRG420 (Version 10) Week 4 Individual- Simple Commission Calculation Program Part 3Modify the Week Three Java finishing using Java NetBeans IDE to meet these additional and changed business requirements* The use will now compare the quantity one-year compensation of at least both gross revenuepersons. * It will calculate the additional step of gross sales that each salesperson must achieve to match or exceed the higher of the two earners. * The application should ask for the realize of each salesperson being compared.The Java application should also meet these technical requirements* The application should have at least ace fall apart, in addition to the applications controlling class. * The source code must demonstrate the use of Array or ArrayList. * There should be graceful documentation in the source code.Source Code/***Program Simple Commission Calculation Program Part 3Purpose to calculates and display the agree annual compensation of a salesperson. ProgrammerClass PRG420InstructorCreation DateProgrammer Modification DatePurpose to add appellation of sales person and also functionality to manage the list of sales persons an comparing their annual compensation Program Summary This program will calculate and display the total annual compensation of a salesperson. Here in this program the salary of the salesman and its commission rate is fixe and program accepts sales amount.*/import java.util.ArrayListimport java.util.electronic scannerimport java.text.NumberFormatclass SalesPerson private final twin fixed_Salary = 35750.00private final parlay commission_Rate = 12.0private final double sales_Target = 125250.00private String nameprivate double annual_Sales//default constructor ordinary SalesPerson() name = Unknownannual_Sales = 0.0//parameterized constructorpublic SalesPerson(String nm,double aSale) name = nmannual_Sales = aSale//getter method for the namepublic String get attend()return name//setter method to set namepublic void setName(Str ing nm)name = nm//getter method for the annual salespublic double getAnnualSales()return annual_Sales//method to set the value of annual salepublic void setAnnualSales(double aSale) annual_Sales = aSale//method to calcualte and get commissionpublic double commission ()double commission = 0if(annual_Sales= (sales_Target*(80/100))) //80% of the sales targetif(annual_Sales= sales_Target)commission = sales_Target * (commission_Rate/100.0) + (annual_Sales- sales_Target)* (75.0/100.0) elsecommission = annual_Sales * (commission_Rate/100.0) return commission //method to calcualte and get annual compensationpublic double annualCompensation ()return fixed_Salary + commission()public class Main public static void main(String args)//array list to have a collection of sales personsArrayList sales_Persons = new ArrayList()//create an object of Scanner calss to get the keyboard input Scanner input = new Scanner(System.in)do//prompt the user to enter nameSystem.out.print(Enter salesperson name (st op to EXIT) ) String name = input.nextLine().trim()if(name.equalsIgnoreCase(stop))break//creating an object of SalesPerson classSalesPerson sales_Person = new SalesPerson()//set name of sales personsales_Person.setName(name)//prompt the user to enter the annual salesSystem.out.print(Enter the annual sales )double sale = input.nextDouble()//set the value of annual sale of sales person object sales_Person.setAnnualSales(sale)//add sales Person to array listsales_Persons.add(sales_Person)//read a blank lineinput.nextLine()while(true)//getting the 2 momentimum annual compensationdouble min = -1double secondMin = -1if(sales_Persons.size()=3)//intilizationdouble firstValue = sales_Persons.get(0).annualCompensation() double secondValue = sales_Persons.get(1).annualCompensation()//intechanging if in reverse orederif (firstValue secondValue) min = firstValuesecondMin = secondValueelse min = secondValuesecondMin = firstValuedouble nextElement = -1//compring the 2 to n valuesfor (int i = 2 i sales_Persons.size() i++) nextElement = sales_Persons.get(i).annualCompensation() if (nextElement min) secondMin = minmin = nextElementelse if (nextElement secondMin) secondMin = nextElement//displaying resultNumberFormat nf = NumberFormat.getCurrencyInstance()//All salespersons and their total annual compensation System.out.println()System.out.printf(String.format(%-20s%-20s,Name, Total annual compensation )) System.out.println()for(SalesPerson salesperson sales_Persons)System.out.printf(String.format(%-20s%20s,salesperson.getName(), nf.format(salesperson.annualCompensation()))) System.out.println()//dipslyaing the all sales persons additional amount of sales other the 2 memebrs who have minimum sales System.out.println()for(int i=0 i sales_Persons.size()i++)double compensation = sales_Persons.get(i).annualCompensation()if(compensation == min compensation == secondMin) continueSystem.out.println(Name of Salesperson +sales_Persons.get(i).getName()) System.out.println(The to tal annual compensation +nf.format(compensation))System.out.println(Total SalesTotal Compensation)double sale = sales_Persons.get(i).getAnnualSales() for(double j =sale j

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.