1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
fgiga [73]
1 year ago
15

In Chapter 8, Programming Exercise 6 you created a Salesperson class with fields for an ID number and sales values. Now, create

an application that allows a user to enter values for an array of seven Salesperson objects. Offer the user the choice of displaying the objects in ascending order by either (I)D number or (S)ales value.
An example of the program is shown below:

Enter an ID number
100
Enter sales value
250
Enter an ID number
101
Enter sales value
500.25
Enter an ID number
103
Enter sales value
600.50
Enter an ID number
106
Enter sales value
78
Enter an ID number
105
Enter sales value
80.2
Enter an ID number
102
Enter sales value
45.68
Enter an ID number
104
Enter sales value
120
By which field do you want to sort?
(I)d number or (S)ales
I

ID 100 sales: 250.0
ID 101 sales: 500.25
ID 102 sales: 45.68
ID 103 sales: 600.5
ID 104 sales: 120.0
ID 105 sales: 80.2
ID 106 sales: 78.0
Computers and Technology
1 answer:
sattari [20]1 year ago
5 0

Using the knowldge in computional language in Java it is possible to write a code that create an application that allows a user to enter values for an array of seven Salesperson objects.

<h3>Writing the code in Java</h3>

import java.util.*;

public class Salesperson

{

private int ID;

private double annualSales;

public Salesperson(int ID, double annualSales)

{

this.ID = ID;

this.annualSales = annualSales;

}

public int getID()

{

return ID;

}

public void setID(int ID)

{

this.ID = ID;

}

public double getAnnualSales()

{

return annualSales;

}

public void setAnnualSales(double annualSales)

{

this.annualSales = annualSales;

}

public String toString()

{

return "Salesperson ID: " + ID + ", annual sales: " + annualSales;

}

}

// you created a Salesperson class with fields for an ID number and sales values. Now,

// create an application that allows a user to enter values for an array of seven Salesperson objects.

// Offer the user the choice of displaying the objects in order by either ID number or sales value.

// Save the application as SalespersonSort.java

public class SalespersonSort

{

public static void main(String[] args)

{

Salesperson[] array = new Salesperson[7];

Scanner in = new Scanner(System.in);

for(int i=0; i<array.length; i++){

System.out.print("\nEnter ID number of Sales Person "+ (i+1) + " :");

int ID = in.nextInt();

System.out.print("\nEnter Annual Sales of Sales Person "+ (i+1) + " :");

double sales = in.nextDouble();

array[i] = new Salesperson(ID,sales);

}

System.out.println("Do you want to sort by ID or sales? (Enter ID or sales):");

String choice = in.next();

if(choice.equalsIgnoreCase("ID")){

for(int i=0; i<array.length; i++){

int min = i;

for(int j=i; j<array.length; j++){

if(array[j].getID() < array[min].getID())

min = j;

}

Salesperson temp = array[i];

array[i] = array[min];

array[min] = temp;

}

System.out.println("Sales sorted by ID are ");

for(int i=0; i<array.length; i++)

System.out.println(array[i]);

}

else{

for(int i=0; i<array.length; i++){

int min = i;

for(int j=i; j<array.length; j++){

if(array[j].getAnnualSales() < array[min].getAnnualSales())

min = j;

}

Salesperson temp = array[i];

array[i] = array[min];

array[min] = temp;

}

System.out.println("Sales sorted by Annual Sales are ");

for(int i=0; i<array.length; i++)

System.out.println(array[i]);

}

See more about Java at: brainly.com/question/12978370

#SPJ1

You might be interested in
Pls awnser if awnser is wrong I will unmark brainliest
choli [55]

Answer: i think 1, 3, and 4

Explanation:

3 0
2 years ago
You have spent $4,000 on liquor for your bar. Your bar sales have been $24,000. What is your cost of sales for liquor, expressed
amid [387]

Answer:

17%

Explanation:

Given parameters:

Cost price of liquor = $4000

Total sale = $24000

Unknown:

Percentage cost of sale for liquor = ?

Solution:

To find the percentage cost of sale;

       %Cost of sale of liquor = \frac{cost price of liquor}{Total cost of sale }   x 100

Input the variables;

       %Cost of sale of liquor = \frac{4000}{24000}  x 100 = 16.67% = 17%

8 0
2 years ago
The _____ option will allow a user to remove text from one location and keep it for use later on the clipboard.
ValentinkaMS [17]

I believe the answer is the "cut" option?

8 0
3 years ago
What principle of interaction is John using?
Rainbow [258]

Answer:

but which john

Explanation:

man people don't make sense you more man

8 0
3 years ago
Read 2 more answers
1.
aliya0001 [1]
#1 is D #2 is B #3 is A #4 is D #5 is B
3 0
2 years ago
Read 2 more answers
Other questions:
  • Ann wants to download Adobe Acrobat software from the Internet. Prior to downloading, a standardized online contract appears on
    7·1 answer
  • Software design and implementation are interleaved activities. The level of detail in the design depends on the type of system b
    5·1 answer
  • What is a bug?
    11·2 answers
  • What are the factors affecting the purchasing decision for dbms software?
    7·2 answers
  • Precautionary measures to be observed when using ICT tools​
    15·1 answer
  • write a C program the prints out the size of variables with the following C data types- int, long, unsigned, long long, double,
    7·1 answer
  • What is the advantage of maintaining a list of keywords while creating a design blueprint?
    13·2 answers
  • Which spreadsheet toolbar displays options such as Cut and Paste?
    11·2 answers
  • Why is it so important to adhere to principles that have been put forth by reputable organizations to ensure that you are mainta
    10·1 answer
  • 3.6 Code Practice Edhesive. (PYTHON LANGUAGE)
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!