Java Programming
Java Programming
8th Edition
ISBN: 9781305981829
Author: Joyce Farrell
Publisher: Cengage Limited
Expert Solution & Answer
Book Icon
Chapter 9, Problem 4PE

Explanation of Solution

Program:

File name: “Salesperson.java

//Define a class named Salesperson

public class Salesperson

{

    //Declare the private variables

    private int id;

    private double sales;

    /*Define a method named Salesperson

    that takes two arguments*/

    Salesperson(int idNum, double amt)

    {

        //Assign the values

        id = idNum;

        sales = amt;

    }

    //Define a get method that returns the ID number

    public int getId()

    {

        //Return the value

        return id;

    }

    //Define a get method that returns the sales value

    public double getSales()

    {

        //Return the value

        return sales;

    }

    //Define a set method that takes the ID number

    public void setId(int idNum)

    {

        //Assign the value

        id = idNum;

    }

    //Define a set method that takes the sales value

    public void setSales(double amt)

    {

        //Assign the value

        sales = amt;

    }

}

File name: “SalespersonSort.java

//Import necessary header files

import javax.swing.*;

//Define a class named SalespersonSort

public class SalespersonSort

{

    //Define a main method

    public static void main(String[] args)

    {

        //Declare an array to store seven Salesperson objects

        Salesperson[] salespeople = new Salesperson[7];

        //Declare the variables

        int x;

        int id;

        double sales;

        String order;

        String message = "";

        //For loop to be executed until x exceeds 7

        for(x = 0; x < salespeople.length; ++x)

        {

            //Prompt the user to enter an ID number

id = Integer.parseInt(JOptionPane.showInputDialog(null,

            "Enter an ID number"));

            //Prompt the user to enter the sales value

sales = Double.parseDouble(JOptionPane.showInputDialog(null,

            "Enter sales value"));

            salespeople[x] = new Salesperson(id, sales);

        }

        /*Prompt the user to enter the choice of displaying

the objects in order by either ID number or sales value*/

        order = JOptionPane.showInputDialog(null,

         "By which field do you want to sort?\n" +

         "(I)d number or (S)ales");

        //If the user enters the choice, ID number

        if(order.charAt(0) == 'I')

            //Function call

            sortById(salespeople);

        //Else the user enters the choice, sales value

        else

            //Function call

            sortBySales(salespeople);

        //For loop to be executed until x exceeds 7

        for(x = 0; x < salespeople...

Blurred answer
Students have asked these similar questions
(A) A cellular system has 12 microcells with 10 channels per cell. The microcells are split into 3 microcells, and each microcell is further split into 4 picocells. Determine the number of channels available in system after splitting into picocelles.
Question 8 (10 points) Produce a relational schema diagram that corresponds to the following ER diagram for a Vacation Property Rentals database. Your relational schema diagram should include primary & foreign keys. Upload your relational schema diagram as a PDF document. Don't forget that the relation schemas for "Beach Property" and "Mountain Property" should each have primary keys. FYI: "d" in this notation denotes a subclass. Figure 2: ER Diagram for Question 8 id first RENTER name middle last address phone email 1 signs N id begin date RENTAL AGREEMENT end date amount N street address books city id 1 state address num. rooms PROPERTY zip code base rate type propertyType blocks to beach activity "B" "M" BEACH PROPERTY MOUNTAIN PROPERTY
Notes: 1) Answer All Question, 2) 25 points for each question QI Figurel shows the creation of the Frequency Reuse Pattern Using the Cluster Size K: (A) illustrates how i and j can be used to locate a co-channel cell. huster 3 Cluster Cluster 2 X=7(i=2,j1)
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,