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...
Trending nowThis is a popular solution!
Chapter 9 Solutions
MINDTAPV2.0 JAVA PROGRAMMING 2021, 1TERM
- What are the similarities and differences between massively parallel processing systems and grid computing. with referencesarrow_forwardModular Program Structure. Analysis of Structured Programming Examples. Ways to Reduce Coupling. Based on the given problem, create an algorithm and a block diagram, and write the program code: Function: y=xsinx Interval: [0,π] Requirements: Create a graph of the function. Show the coordinates (x and y). Choose your own scale and show it in the block diagram. Create a block diagram based on the algorithm. Write the program code in Python. Requirements: Each step in the block diagram must be clearly shown. The graph of the function must be drawn and saved (in PNG format). Write the code in a modular way (functions and the main part should be separate). Please explain and describe the results in detail.arrow_forwardBased on the given problem, create an algorithm and a block diagram, and write the program code: Function: y=xsinx Interval: [0,π] Requirements: Create a graph of the function. Show the coordinates (x and y). Choose your own scale and show it in the block diagram. Create a block diagram based on the algorithm. Write the program code in Python. Requirements: Each step in the block diagram must be clearly shown. The graph of the function must be drawn and saved (in PNG format). Write the code in a modular way (functions and the main part should be separate). Please explain and describe the results in detail.arrow_forward
- Based on the given problem, create an algorithm and a block diagram, and write the program code: Function: y=xsinx Interval: [0,π] Requirements: Create a graph of the function. Show the coordinates (x and y). Choose your own scale and show it in the block diagram. Create a block diagram based on the algorithm. Write the program code in Python. Requirements: Each step in the block diagram must be clearly shown. The graph of the function must be drawn and saved (in PNG format). Write the code in a modular way (functions and the main part should be separate). Please explain and describe the results in detail.arrow_forwardQuestion: Based on the given problem, create an algorithm and a block diagram, and write the program code: Function: y=xsinx Interval: [0,π] Requirements: Create a graph of the function. Show the coordinates (x and y). Choose your own scale and show it in the block diagram. Create a block diagram based on the algorithm. Write the program code in Python. Requirements: Each step in the block diagram must be clearly shown. The graph of the function must be drawn and saved (in PNG format). Write the code in a modular way (functions and the main part should be separate). Please explain and describe the results in detail.arrow_forward23:12 Chegg content://org.teleg + 5G 5G 80% New question A feed of 60 mol% methanol in water at 1 atm is to be separated by dislation into a liquid distilate containing 98 mol% methanol and a bottom containing 96 mol% water. Enthalpy and equilibrium data for the mixture at 1 atm are given in Table Q2 below. Ask an expert (a) Devise a procedure, using the enthalpy-concentration diagram, to determine the minimum number of equilibrium trays for the condition of total reflux and the required separation. Show individual equilibrium trays using the the lines. Comment on why the value is Independent of the food condition. Recent My stuff Mol% MeOH, Saturated vapour Table Q2 Methanol-water vapour liquid equilibrium and enthalpy data for 1 atm Enthalpy above C˚C Equilibrium dala Mol% MeOH in Saturated liquid TC kJ mol T. "Chk kot) Liquid T, "C 0.0 100.0 48.195 100.0 7.536 0.0 0.0 100.0 5.0 90.9 47,730 928 7,141 2.0 13.4 96.4 Perks 10.0 97.7 47,311 87.7 8,862 4.0 23.0 93.5 16.0 96.2 46,892 84.4…arrow_forward
- You are working with a database table that contains customer data. The table includes columns about customer location such as city, state, and country. You want to retrieve the first 3 letters of each country name. You decide to use the SUBSTR function to retrieve the first 3 letters of each country name, and use the AS command to store the result in a new column called new_country. You write the SQL query below. Add a statement to your SQL query that will retrieve the first 3 letters of each country name and store the result in a new column as new_country.arrow_forwardWe are considering the RSA encryption scheme. The involved numbers are small, so the communication is insecure. Alice's public key (n,public_key) is (247,7). A code breaker manages to factories 247 = 13 x 19 Determine Alice's secret key. To solve the problem, you need not use the extended Euclid algorithm, but you may assume that her private key is one of the following numbers 31,35,55,59,77,89.arrow_forwardConsider the following Turing Machine (TM). Does the TM halt if it begins on the empty tape? If it halts, after how many steps? Does the TM halt if it begins on a tape that contains a single letter A followed by blanks? Justify your answer.arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,