Question
Rebuild Lab 3 Salesperson Bonus to read the inputs from an XML file of your own design. Ensure your program can handle any number of
Rebuild Lab 3 Salesperson Bonus to read the inputs from an XML file of your own design. Ensure your program can handle any number of input lines from the file.
Project Name: Lab_9_Salesperson_Bonus
Below is the code from Lab 3 Salesperson Bonus:
public static void main(String[] args) {
// TODO code application logic here
Scanner input = new Scanner(System.in);
//Input information
double[] sales = new double[10];//Declaring array to store sales amounts
double[] bonus = new double[10];//Declaring array to store bonus after calculation
double totalsales = 0, totalbonus = 0;//Variables declared to store total sales and bonus
//Entering the values for the sales
System.out.println("Enter the sales amount for the 10 salespeople\n");
//Using loop to enter the sales amount for 10 salespeople
for(int i =0;i<10;i++)
{
System.out.println("Amount for salesperson " + (i+1) + ":");
sales[i] = input.nextDouble();
totalsales = sales[i]+totalsales;//Calculating the total sales and stores them in the variable
}
//Calculating the bonus using the loop
for(int i =0;i<10;i++)
{
if(sales[i]>60000)//if to check the sales is greater than 60000
{
bonus[i] = (sales[i]*5)/100;//Calculating the bonus with 5% and stores in the array
totalbonus = totalbonus + bonus[i];//Calculating the total bonus
}
else//Sales amount is less than 60000
{
bonus[i] = (sales[i]*2)/100;//Calcualting the bonus amount using 2% bonus
totalbonus = totalbonus + bonus[i]; //Total bonus is calculating
}
}
//Prints results
System.out.println("\nTOTAL SALES: $"+ (int)Math.round(totalsales));
System.out.println("\nTOTAL SALES BONUS: $"+ (int)Math.round(totalbonus));
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
modify the code to read inputs from an XML file we need to design an XML structure to hold sales dat...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started