Concept explainers
Explanation of Solution
Program:
File name: “CertOfDeposit.java”
//Import necessary header files
import java.time.LocalDate;
//Define a class named CertOfDeposit
public class CertOfDeposit
{
//Declare the private variables
private int certificateNumber;
private String lastName;
private double balance;
private LocalDate issueDate;
private LocalDate maturityDate;
/*Define a constructor that sets the instance variables
to class CertOfDeposit */
public CertOfDeposit(int certificateNumber,String lastName,double balance, LocalDate issueDate)
{
//Refers to the instance variables
this.certificateNumber=certificateNumber;
this.lastName=lastName;
this.balance=balance;
this.issueDate=issueDate;
this.maturityDate=issueDate.plusYears(1);
}
//Define a method that sets the certificate number
public void setCertificateNumber(int certificateNumber)
{
this.certificateNumber=certificateNumber;
}
//Define a method that sets the last name
public void setLastName(String lastName)
{
this.lastName=lastName;
}
//Define a method that sets the balance amount
public void setBalance(double balance)
{
this.balance=balance;
}
//Define a method that sets the issue date
public void setIssueDate(LocalDate issueDate)
{
this.issueDate=issueDate;
}
//Define a method that sets the maturity date
public void setMaturityDate(LocalDate maturityDate)
{
this.maturityDate=maturityDate;
}
//Define a method that returns the certificate number
public int getCertificateNumber()
{
//Return the value
return certificateNumber;
}
//Define a method that returns the last name
public String getLastName()
{
//Return the value
return lastName;
}
//Define a method that returns the balance amount
public double getBalance()
{
//Return the value
return balance;
}
//Define a method that returns the issue date as LocalDate object
public LocalDate getIssueDate()
{
//Return the value
return issueDate;
}
//Define a method that returns the maturity date as LocalDate object
public LocalDate getMaturityDate()
{
//Return the value
return maturityDate;
}
}
File name: “CertOfDepositArray.java”
//Import necessary header files
import java.time.LocalDate;
import java.util.Scanner;
//Define a class named CertOfDepositArray
public class CertOfDepositArray
{
//Define a main method
public static void main(String[] args)
{
//Declare the variables
int certificateNumber;
String name;
double balance;
int day;
int month;
int year;
final int size=5;
//Create an object for Scanner class
Scanner scanner=new Scanner(System...
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
- JAVA I cannot figure this one out no matter what I do I cannot get it to run. Please write it in a student way not in an too advance way. Write an application containing three parallel arrays that hold 10 elements each. The first array hold four-digit student ID numbers, the second array holds first names, and the third array holds the students’ grade point averages. Use dialog boxes to accept a student ID number and display the student’s first name and grade point average. If a match is not found, display an error message that includes the invalid ID number and allow the user to search for a new ID number.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_forwardThis class will allow a user to enter 5 scores into an array. It will then rearrange the datain descending order and calculate the mean for the data set.Attributes: data[]— the array which will contain the scores mean — the arithmetic average of the scoresMethods: Average — the constructor. It will allocate memory for the array. Use a forloop to repeatedly display a prompt for the user which should indicate that userCopyright © 2019 Pearson Education, Inc., Hoboken NJshould enter score number 1, score number 2, etc. Note: The computer startscounting with 0, but people start counting with 1, and your prompt should accountfor this. For example, when the user enters score number 1, it will be stored inindexed variable 0. The constructor will then call the selectionSort and thecalculateMean methods. calculateMean — this is a method that uses a for loop to access each scorein the array and add it to a running total. The total divided by the number ofscores (use the length of the array),…arrow_forward
- Java:arrow_forwardplease write in javaarrow_forwardUsing jGRASP please write this code You are writing a program to convert Ounces to Grams for 3 different measurements of Ounces. Create a class called ConversionsOunces that contains the following: a data member for an array to hold 3 different measurements in Ounces. a constructor that accepts a parameter for an array that stores the 3 different measurements in Ounces a method that calculates the total Ounces input for the 3 different measurements of Ounces a method that calculates the total Grams by converting the total Ounces to total Grams. To convert Ounces to Grams, multiply total Ounces by a factor of 28.35 Create a program called ConversionsOuncesDemo that references the ConversionsOunces class that contains the following: an array to store the 3 different measurements in Ounces input by the user a for loop that prompts the user to enter the Ounces to be converted so that the user can input 3 different measurements of Ounces create an object that represents the Ounces…arrow_forward
- Please written by computer source In this lab you will create and fill a two-dimensional array of 25 Rectangle objects, arranged in a 5x5 grid. Each Rectangle should have dimensions 100x100, and be arranged on your window so that there is no space between Rectangles. Each Rectangle object should start with one fill color (e.g. white) and when pressed with the mouse it should toggle to a second color (e.g. gray). Pressing a second time on the Rectangle should toggle it’s fill color back to the first color. 3. Use the following template for your main() method. Add missing statements necessary to create your two- dimensional 5x5 Rectangle array and nested for-loops to fill the array with 25 new Rectangle objects, located on your window in a regular 5x5 grid. Make sure to set the mouse-pressed event handler for each new Rectangle. 2. Declare at least two public static variables: a 2D array of Rectangle objects, and a Pad variable: public static Pad pad; public static void main(String[]…arrow_forwardWhen you create a class and want to include the capability to compare its objects so they can use the Array.Sort() or Array.BinarySearch() method, you must Two of these are true. be careful not to override the existing IComparable.CompareTo() method write a CompareTo() method for the class include at least one numeric field within the classarrow_forwardDesign 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_forward
- This is the question - The developers of a free online game named Sugar Smash have asked you to develop a class named SugarSmashPlayer that holds data about a single player. The class contains the following fields: idNumber - the player’s ID number (of type int) name - the player's screen name (of type String) scores - an array of integers that stores the highest score achieved in each of 10 game levels Include get and set methods for each field. The get method for scores should require the game level to retrieve the score for. The set method for scores should require two parameters—one that represents the score achieved and one that represents the game level to be retrieved or assigned. Display an error message if the user attempts to assign or retrieve a score from a level that is out of range for the array of scores. Additionally, no level except the first one should be set unless the user has earned at least 100 points at each previous level. If a user tries to set a score for a…arrow_forwardThis is the question - The developers of a free online game named Sugar Smash have asked you to develop a class named SugarSmashPlayer that holds data about a single player. The class contains the following fields: idNumber - the player’s ID number (of type int) name - the player's screen name (of type String) scores - an array of integers that stores the highest score achieved in each of 10 game levels Include get and set methods for each field. The get method for scores should require the game level to retrieve the score for. The set method for scores should require two parameters—one that represents the score achieved and one that represents the game level to be retrieved or assigned. Display an error message if the user attempts to assign or retrieve a score from a level that is out of range for the array of scores. Additionally, no level except the first one should be set unless the user has earned at least 100 points at each previous level. If a user tries to set a score for a…arrow_forwardHere are what to display on your Pokémon's show page: The pokemon's name The image of the pokemon An unordered list of the Pokemon's types (eg. water, poison, etc). The pokemon's stats for HP, ATTACK, and DEFENSE. module.exports = [ { id: "001", name: "Bulbasaur", img: "http://img.pokemondb.net/artwork/bulbasaur.jpg", type: [ "Grass", "Poison" ], stats: { hp: "45", attack: "49", defense: "49", spattack: "65", spdefense: "65", speed: "45" }, ]; Routes Your app should use RESTful routes: Index GET /pokemon Show GET /pokemon/:id New GET /pokemon/new Edit GET /pokemon/:id/edit Create POST /pokemon Update PUT /pokemon/:id Destroy DELETE /pokemon/:idarrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage