Question

In: Computer Science

Instructions Create an application to accept data for an array of five CertOfDeposit objects, and then...

Instructions

Create an application to accept data for an array of five CertOfDeposit objects, and then display the data.

import java.time.*;
public class CertOfDeposit {
private String certNum;
private String lastName;
private double balance;
private LocalDate issueDate;
private LocalDate maturityDate;
public CertOfDeposit(String num, String name, double bal, LocalDate issue) {
}
public void setCertNum(String n) {
}
public void setName(String name) {
}
public void setBalance(double bal) {
}
public void issueDate(LocalDate date) {
}
public String getCertNum() {
}
public String getName() {
}
public double getBalance() {
}
public LocalDate getIssueDate() {
}
public LocalDate getMaturityDate() {
}
}

---------------------------------------------------------------------------------------------------------------

import java.util.*;
import java.time.*;
public class CertOfDepositArray {
public static void main(String[] args) {
// Write your code here
}
public static void display(CertOfDeposit cd, int num) {
System.out.pritnln(, "Certificate " + num +
"\nName: " + cd.getCertNum() + " " +
cd.getName() + " Balance: $" + cd.getBalance() +
"\nIssued: " + cd.getIssueDate() +
"\nMatures: " + cd.getMaturityDate()););
}
}

Solutions

Expert Solution

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Scanner;

class CertOfDeposit {
        private String certNum;
        private String lastName;
        private double balance;
        private LocalDate issueDate;
        private LocalDate maturityDate;

        public CertOfDeposit(String num, String name, double bal, LocalDate issue) {
                certNum = num;
                lastName = name;
                balance = bal;
                issueDate = issue;
                maturityDate = issueDate.plusYears(1);
        }

        public void setCertNum(String n) {
                certNum = n;
        }

        public void setName(String name) {
                lastName = name;
        }

        public void setBalance(double bal) {
                balance = bal;
        }

        public void issueDate(LocalDate date) {
                issueDate = date;
        }

        public String getCertNum() {
                return certNum;
        }

        public String getName() {
                return lastName;
        }

        public double getBalance() {
                return balance;
        }

        public LocalDate getIssueDate() {
                return issueDate;
        }

        public LocalDate getMaturityDate() {
                return maturityDate;
        }
}

public class CertOfDepositArray {
        public static void main(String[] args) {
                // Write your code here
                Scanner in = new Scanner(System.in);
                DateTimeFormatter dateformatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                
                CertOfDeposit certs[] = new CertOfDeposit[5];
                
                for(int i=0; i<5; i++) {
                        
                        System.out.println("Enter certificate number: ");
                        String num = in.nextLine();
                        System.out.println("Enter certificate name: ");
                        String name = in.nextLine();
                        System.out.println("Enter balance: ");
                        Double bal = Double.parseDouble(in.nextLine());
                        System.out.println("Enter issue date: ");
                        LocalDate issueDate = LocalDate.parse(in.nextLine(), dateformatter);
                        
                        certs[i] = new CertOfDeposit(num, name, bal, issueDate);
                        System.out.println();
                }

                for(int i=0; i<5; i++) {
                        display(certs[i], i+1);
                }
                
                in.close();
        }

        public static void display(CertOfDeposit cd, int num) {
                System.out.println("Certificate " + num +
                "\nName: " + cd.getCertNum() + " " +
                cd.getName() + " Balance: $" + cd.getBalance() +
                "\nIssued: " + cd.getIssueDate() +
                "\nMatures: " + cd.getMaturityDate());
                }
}


Please upvote, as i have given the exact answer as asked in question. Still in case of any issues in code, let me know in comments. Thanks!


Related Solutions

Create an application containing an array that stores 5 integers. The application should call five methods...
Create an application containing an array that stores 5 integers. The application should call five methods from Array2 class that in turn (1) display all the integers, (2) display all the integers in reverse order, (3) display the sum of the integers, (4) display all values less than a limiting argument, and (5) display all values that are higher than the calculated average value. Save the file as ArrayTest.java.
Create a windows application that contains two TextBox objects and two Button objects. One of the...
Create a windows application that contains two TextBox objects and two Button objects. One of the TextBox objects and one of the buttons are initially invisible. The first textbox should be used to input a password. The textbox should be masked to some character of your choice so that the characters entered by the user are not seen on the screen. When the user clicks the first button, the second TextBox object and button object should be displayed with a...
JAVASCRIPT Create an array of 5 objects named "movies" Each object in the movies array, should...
JAVASCRIPT Create an array of 5 objects named "movies" Each object in the movies array, should have the following properties: Movie Name Director Name Year Released WasSuccessful (this should be a boolean and at least 2 should be false) Genre Loop through all of the objects in Array If the movie is successful, display all the movie information on the page. These movies were a success: Title: Forrest Gump Year Realeased: 1994 Director: Robert Zemeckis Genre: Comedy
Javascript array of objects: I'm trying to get the input into an array of objects, and...
Javascript array of objects: I'm trying to get the input into an array of objects, and then display the information in a table using a for loop, but I don't think my path is right <!DOCTYPE html> <head> <title>Form</title> <meta charset="utf-8" /> <style media="screen"> h1 { text-align: center; } div { background-color: #pink; border: 2px solid green; padding: 15px; margin: 65px; } </style> <script> var list = []; total = 0; text = ""; function Product(item, quantity, costs){ this.item =...
Objectives: 1. Create classes to model objects Instructions: 1. Create a new folder named Lab6 and...
Objectives: 1. Create classes to model objects Instructions: 1. Create a new folder named Lab6 and save all your files for this lab into this new folder. 2. You can use any IDE (such as SciTE, NetBeans or Eclipse) or any online site (such as repl.it or onlinegdb.com) to develop your Java programs 3. All your programs must have good internal documentation. For information on internal documentation, refer to the lab guide. Problems [30 marks] Problem 1: The Account class...
Objectives: 1. Create classes to model objects Instructions: 1. Create a new folder named Lab6 and...
Objectives: 1. Create classes to model objects Instructions: 1. Create a new folder named Lab6 and save all your files for this lab into this new folder. 2. You can use any IDE (such as SciTE, NetBeans or Eclipse) or any online site (such as repl.it or onlinegdb.com) to develop your Java programs 3. All your programs must have good internal documentation. For information on internal documentation, refer to the lab guide. Problem : The Fraction class (Filename: TestFraction.java) Design...
Please create an array of Leg objects, one constructor that takes three parameters as constant C...
Please create an array of Leg objects, one constructor that takes three parameters as constant C string, and one number representing the distance in miles between the two cities Write a code block to create a static array (that is, not dynamic and not a vector) of 3 Leg objects using city names of your choosing. That's THREE objects, each created using THREE parameters. For example, the Leg class declaration looked like, class Leg { const char* const startCity; const...
please use C++ Create a class named Byte that encapsulates an array of 8 Bit objects....
please use C++ Create a class named Byte that encapsulates an array of 8 Bit objects. The Byte class will provide the following member functions: Byte - word: Bit[8] static Bit array defaults to all Bits false + BITS_PER_BYTE: Integer16 Size of a byte constant in Bits; 8 + Byte() default constructor + Byte(Byte) copy constructor + set(Integer): void sets Bit to true + clear(): void sets to 0 + load(Byte): void sets Byte to the passed Byte + read():...
Create an application containing an array that stores 20 prices, such as 2.34, 7.89,1.34, and so...
Create an application containing an array that stores 20 prices, such as 2.34, 7.89,1.34, and so on. The application should (1) display the sum of all the prices, (2) display all values less than 5.00, (3) calculate the average of the prices, and (4) display all values that are higher than the calculated average value. Write a program in Java which performs the sort operation. The main method accepts ten numbers in an array and passes that to the method...
Create a Java Application that implements a Selection sort algorithm to sort an array of 20...
Create a Java Application that implements a Selection sort algorithm to sort an array of 20 unsorted numbers. You should initiate this array yourself and first output the array in its original order, then output the array after it has been sorted by the selection sort algorithm. Create a second Java Application that implements an Insertion sort algorithm to sort the same array. Again, output the array in its original order, then output the array after it has been sorted...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT