a.
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 Salesperson that includes
an integer ID number and a double annual sales amount*/
Salesperson(int idNum, double amt)
{
//Assign the values
id = idNum;
sales = amt;
}
//Define a method to display the id
public int getId()
{
//Return the value
return id;
}
//Define a method to display the annual sales amount
public double getSales()
{
//Return the value
return sales;
}
//Define a method to set the id
public void setId(int idNum)
{
//Assign the value
id = idNum;
}
//Define a method to set the annual sales amount
public void setSales(double amt)
{
//Assign the value
sales = amt;
}
}
File name: “DemoSalesperson...
b.
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 Salesperson that includes
an integer ID number and a double annual sales amount*/
Salesperson(int idNum, double amt)
{
//Assign the values
id = idNum;
sales = amt;
}
//Define a method to display the id
public int getId()
{
//Return the value
return id;
}
//Define a method to display the annual sales amount
public double getSales()
{
//Return the value
return sales;
}
//Define a method to set the id
public void setId(int idNum)
{
//Assign the value
id = idNum;
}
//Define a method to set the annual sales amount
public void setSales(double amt)
{
//Assign the value
sales = amt;
}
}
File name: “DemoSalesperson2...
Trending nowThis is a popular solution!
Chapter 8 Solutions
MindTapV2.0 for Farrell's Java Programming with 2021 Updates, 9th Edition [Instant Access], 1 term
- Create an application named SalesTransactionDemo that declares several SalesTransaction objects and displays their values and their sum. The SalesTransaction class contains the following fields: Name - The salesperson's name (as a string) salesAmount - The sales amount ( as a double) commission - The commission (as a double) RATE - A readonly field that stores the commission rate (as a double). Define a getRate() accessor method that returns the RATE Include three constructors for the class. One constructor accepts values for the name, sales amount, and rate, and when the sales value is set, the constructor computes the commission as sales value times commission rate. The second constructor accepts a name and sales amount, but sets the commission rate to 0. The third constructor accepts a name and sets all the other fields to 0. An overloaded + operatoradds the sales values for two SalesTransaction objects and returns a new SalesTransaction object. In order to prepend the $ to…arrow_forwardCreate a class name Taxpayer. Data fields for Taxpayer include yearly gross income and Social Security number (use an int for the type, and do not use dashes within the Social Security number). Methods include a constructor that requires a value for both data fields and two methods that each return one of the data field values. Write an application named USeTaxpayer that declares an array of 10 Taxpayer objects. Set each Social Security number to 999999999 and each gross income to zero. Display the 10 Taxpayer objects. Save the files as TAxpayer.java and USeTAxpayer.javaarrow_forwardCreate the StockTask1 Java project Create a Stock object class that contains the following information: The symbol of the stock is stored in a private string data field called symbol. The stock's name is stored in a private string data field called name. previousClosingPrice is a private double data area that stores the stock price for the previous day. currentPrice is a private double data area that stores the stock price at the current time. A constructor for creating a stock with the given symbol and name. For the data fields, there are accessor methods (get-methods). For the data fields, there is a mutator method (set-methods). A method named getChangePercent()that returns the percentage changed from previousClosingPrice to currentPrice. Formula:perc_change = (current price - previous closing price) / previous closing price x 100 Create a test class named testStockthat creates a Stockobject with the stock symbol SUNW, the name Sun Microsystems Inc., and the previous closing…arrow_forward
- Complete the following tasks: Design a class named StockTransaction that holds a stock symbol (typically one to four characters), stock name, and price per share. Include methods to set and get the values for each data field. Create the class diagram and write the pseudocode that defines the class. Design an application that declares two StockTransaction objects and sets and displays their values. Design an application that declares an array of 10 StockTransactionobjects. Prompt the user for data for each object, and then display all the values. Design an application that declares an array of 10 StockTransactionobjects. Prompt the user for data for each object, and then pass the array to a method that determines and displays the two stocks with the highest and lowest price per share.arrow_forwardThis is the question I am stuck on - Radio station KJAVA wants a class to keep track of recordings it plays. Create a class named Recording that contains fields to hold methods for setting and getting a Recording’s title, artist, and playing time in seconds. Write an application that instantiates five Recording objects and prompts the user for values for the data fields. Then prompt the user to enter which field the Recordings should be sorted by—(S)ong title, (A)rtist, or playing (T)ime. Perform the requested sort procedure, and display the Recording objects. This is what I have so far - public class Recording { private String song; private String artist; private int playTime; public void setSong(String title) { this.song = title; } public void setArtist(String name) { this.artist = name; } public void setPlayTime(int time) { this.playTime = time; } public String getSong() { return song; } public String…arrow_forwardIntroduction In this project, you will complete a C++ class by writing a copy constructor, destructor, and assignment operator. Furthermore, you will write a tester class and a test program and use Valgrind to check that your program is free of memory leaks. Finally, you will submit your project files on GL. If you have submitted programs on GL using shared directories (instead of the submit command), then the submission steps should be familiar. In this project we develop an application which holds the information about a digital art piece. There are two classes in this project. • The Random class generates data. The implementation of this class is provided. It generates random int numbers for colors. To create an object of this class we need to specify min and max values for the constructor. The colors fall between 30 and 37 inclusively. The Art class generates random colors and stores the color values. You implement the Art class. An object of the Art class is a digital masterpiece.…arrow_forward
- Design a class named CustomerRecord that holds a customer number, name, and address. Include separate methods to 'set' the value for each data field using the parameter being passed. Include separate methods to 'get' the value for each data field, i.e. "return" the field's value. Pseudocode:arrow_forwardUsing oop in java Create a class for Subject containing the Name of the subject and score of the subject. There should be following methods: set: it will take two arguments name and score, and set the values of the attributes. If score is less than 0 or greater than 100.0 then a message should be displayed “Incorrect score” and score should be set to Zero. set: it will take one double value as argument and set the value of score only. If score is less than 0 or greater than 100.0 then a message should be displayed “Incorrect score” and score should be set to Zero. display: it will display the name and score of the subject. Like “Name : Math, Score: 99.9” getScore: it will return the value of score. greaterThan: it will take subject’s object as argument, compare the calling object’s score with argument object’s score and return true if the calling object has greater score.arrow_forwardStatic & Not Final Field: Accessed by every object, Changing Non-Static & Final Field: Accessed by object itself, Non-Changing Static & Final: Accessed by every object, Non-Changing Non-Static & Not Final Field: Accessed by object itself, ChangingRead the following situation and decide how the variables should be defined. You have a class named HeartsPlayerA round of Hearts starts with every player having 13 cardsPlayers then choose 3 cards to “trade” with a player (1st you pass left, 2nd you pass right, 3rd you pass across, 4th you keep)Players then strategically play cards in order to have the lowest scoreAt the end of the round, points are cumulatively totaled for each player.If one player’s total is greater than 100, the game ends and the player with the lowest score wins. 1. How should the following data fields be defined (with respect to final and static)?(a) playerPosition (These have values of North, South, East, or West)(b) directionOfPassing(c) totalScore…arrow_forward
- The xxx_Student class:– Name - the name consists of the First and Last name separated by a space.– Student Id – a whole number automatically assigned in the student class– Student id numbers start at 100. The numbers are assigned using a static variable in the Student class• Include all instance variables• Getters and setters for instance variables• A static variable used to assign the student id starting at 100• A toString method which returns a String containing the student name and id in the format below:Student: John Jones ID: 101 The xxx_Course classA Course has the following information (modify your Course class):– A name– An Array of Students which contains an entry for each Student enrolled in the course (allow for up to 10 students)– An integer variable which indicates the number of students currently enrolled in the course. Write the constructor below which does the following:Course (String name)Sets courseName to nameCreates the students array of size 10Sets number of…arrow_forwardVisual C# - This must be a Universal Windows Application form Starting out a project program called Data Collector Please Define an interface Define an interface called IMeasuringDevice. Add it to your project in its own IMeasuringDevice.cs source file Add the following public method declarations to your new interface: MetricValue. This method will return a decimal that represents the metric value of the most recent measurement that was captured. ImperialValue. This method will return a decimal that represents the imperial value of the most recent measurement that was captured. StartCollecting. This method will start the device running. It will begin collecting measurements and record them. StopCollecting. This method will stop the device. It will cease collecting measurements. GetRawData. This method will retrieve a copy of all of the recent data that the measuring device has captured. The data will be returned as an array of integer values. Comment your new method…arrow_forwardPlease create a java class that contains the following data attributes and methods: private int customerNumber - a unique number assigned to each customer private String firstName - the customer's first name private String lastName - the customer's last name private float balance - the customer's balance get/set Methods for each data attribute public String toString() - Special method to be used when printing a customer Record objectarrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT