Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

/*Write a program to find the winner of a sales contest by determining the sales

ID: 3673050 • Letter: #

Question

/*Write a program to find the winner of a sales contest by determining the salesperson who sells the most units.
The program should first input the number of salespersons.
Then the program should input the number of units sold for each salesperson.
The program should output the number of units that has the largest value.
Include the outputs to following input sequences when turning in your assignment:
4 900 850 950 800
2 900 900
1 900
0
*/
import java.util.Scanner;
public class Sales
{
public static void main (String args[])
{
Scanner stdin = new Scanner(System.in);
System.out. print(" Enter the number of sales person: ");
int numPer = stdin.nextInt();
System.out.println("Enter the number of units sold per salesperson #1: ");
int units = stdin.nextInt();
int max = units;
for (int i =2 ; i<= numPer ; i++ )
{
System.out.print( "Enter number of units sold per salesperson # " +i +":");
units = stdin.nextInt();
if (units > max)
max = units ;
}
System.out.println ("Max units sold is " + max );
System.out.println("The winner of sales contest is saleperson No. " + );
}
}
Please fix my program to add the salesperson who sells the most units . Thank you

Explanation / Answer

import java.util.Scanner;
public class Sales
{

public static void main (String args[])

{

int p=0;

Scanner stdin = new Scanner(System.in);

System.out. print(" Enter the number of sales person: ");

int numPer = stdin.nextInt();

System.out.println("Enter the number of units sold per salesperson #1: ");

int units = stdin.nextInt();

int max = units;

for (int i =2 ; i<= numPer ; i++ )

{

System.out.print( "Enter number of units sold per salesperson # " +i +":");

units = stdin.nextInt();

if (units > max){

max = units ;p = i;

}

}

System.out.println ("Max units sold is " + max );

System.out.println("The winner of sales contest is saleperson No. " + p);

}

}