MINDTAPV2.0 JAVA PROGRAMMING 2021, 1TERM
MINDTAPV2.0 JAVA PROGRAMMING 2021, 1TERM
9th Edition
ISBN: 9780357505526
Author: FARRELL
Publisher: CENGAGE L
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
4G+ Vo) % 1.1. LTE1 : Q B NIS شوز طبي ۱:۱۷ کا A X حاز هذا على إعجاب Mohamed Bashar. MEDICAL SHOE شوز طبي ممول . اقوى عرض بالعراق بلاش سعر القطعة ١٥ الف سعر القطعتين ٢٥ الف سعر 3 قطع ٣٥ الف القياسات : 40-41-42-43-44- افحص وكدر ثم ادفع خدمة التوصيل 5 الف لكافة محافظات العراق ופרסם BNI SH ופרסם DON JU WORLD DON JU MORISO DON JU إرسال رسالة III Messenger التواصل مع شوز طبي تعليق باسم اواب حمید
A manipulator is identified by the following table of parameters and variables:a. Obtain the transformation matrices between adjacent coordinate frames and calculate the global transformation matrix.
Which tool takes the 2 provided input datasets and produces the following output dataset? Input 1: Record First Last Output: 1 Enzo Cordova Record 2 Maggie Freelund Input 2: Record Frist Last MI ? First 1 Enzo Last MI Cordova [Null] 2 Maggie Freelund [Null] 3 Jason Wayans T. 4 Ruby Landry [Null] 1 Jason Wayans T. 5 Devonn Unger [Null] 2 Ruby Landry [Null] 6 Bradley Freelund [Null] 3 Devonn Unger [Null] 4 Bradley Freelund [Null] OA. Append Fields O B. Union OC. Join OD. Find Replace Clear selection
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,