Question

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

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

Use these classes and this code template to solve the problem:

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() {

    }

}

and

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()););

    }

}



Must be able to pass these tests:

Test 1:

101
Barnes
100.50
1
6
2018
102
Rodgers
200.75
2
12
2006
103
Stark
275.00
3
15
2007
104
Potts
700.34
5
23
2011
105
Banner
1005.56
8
4
2016

Test 2:
95
Wayne
123
9
8
1998
96
Allen
345.56
10
11
1999
97
Prince
67.50
11
14
1991
98
Gordon
789.67
12
31
1994
99
Jordan
600.66
7
7
1997

Homework Answers

Answer #1
import java.util.*;  
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.lang.*;

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;
    }

    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 Main {

    public static void main(String[] args) {
        //creating Array of the class CertOfDeposit
        CertOfDeposit[] cd = new CertOfDeposit[5];
        //Getting The Input
        for( int i = 0; i < 5;i++ ){
            Scanner myObj = new Scanner(System.in);  // Create a Scanner object
            String certNum = myObj.nextLine();     
            String name = myObj.nextLine();     
            double bal = myObj.nextDouble();
            int date = myObj.nextInt();
            int month = myObj.nextInt();
            int year = myObj.nextInt();
            try{
                LocalDate dateInstance = LocalDate.of(year, month, date);    
                cd[i] = new CertOfDeposit(certNum,name,bal,dateInstance);         
            }
            catch(Exception e){ //If the date is not proper then current date will store in IssuedDate variable
                LocalDate lt = LocalDate.now(); 
                cd[i] = new CertOfDeposit(certNum,name,bal,lt);         
            }
        }
        // Function call to display values
        for( int i = 0; i < 5;i++ ){
            display(cd[i],new Integer(cd[i].getCertNum()));
        }
    }

    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());

    }

}

Output:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a pseudocode for the following java programs: public class Item {    private String name;...
Write a pseudocode for the following java programs: public class Item {    private String name;    private double cost;    public Item(String name, double cost) {        this.name = name;        this.cost = cost;    }    public String getName() {        return name;    }    public void setName(String name) {        this.name = name;    }    public double getCost() {        return cost;    }    public void setCost(double cost) {...
Write an application that asks a user to enter an integer. Display a statement that indicates...
Write an application that asks a user to enter an integer. Display a statement that indicates whether the integer is even or odd. ------------------------------------------ import java.util.Scanner; class EvenOdd {     public static void main(String[] args) {         // Write your code here     }     public static boolean isEven(int number) {     } }
How do I get this portion of my List Iterator code to work? This is a...
How do I get this portion of my List Iterator code to work? This is a portion of the code in the AddressBookApp that I need to work. Currently it stops at Person not found and if it makes it to the else it gives me this Exception in thread "main" java.lang.NullPointerException    at AddressBookApp.main(AddressBookApp.java:36) iter.reset(); Person findPerson = iter.findLastname("Duck"); if (findPerson == null) System.out.println("Person not found."); else findPerson.displayEntry(); findPerson = iter.findLastname("Duck"); if (findPerson == null) { System.out.println("Person not found.");...
Utilize the code from last week Add a default, full, and copy constructor. Also add a...
Utilize the code from last week Add a default, full, and copy constructor. Also add a constructor that allows you to specify only the name of the video game with no high score or times played specified. Adjust your code to demonstrate use of all 4 constructors and output of the resulting objects. #include <iostream> #include <string> #include <iomanip> using namespace std; class VideoGame { private:     string name;     int highScore;     int numOfPlays; public:     VideoGame() {        ...
Modify the Employee9C superclass so that is an abstract superclass with a constructor to set its...
Modify the Employee9C superclass so that is an abstract superclass with a constructor to set its variables (firstName and lastName). It should contain an abstract method called payPrint. Below is the source code for the Employee9C superclass: public class Employee9C {    //declaring instance variables private String firstName; private String lastName; //declaring & initializing static int variable to keep running total of the number of paychecks calculated static int counter = 0;    //constructor to set instance variables public Employee9C(String...
I am a beginner when it comes to java codeing. Is there anyway this code can...
I am a beginner when it comes to java codeing. Is there anyway this code can be simplified for someone who isn't as advanced in coding? public class Stock { //fields private String name; private String symbol; private double price; //3 args constructor public Stock(String name, String symbol, double price) { this.name = name; this.symbol = symbol; setPrice(price); } //all getters and setters /** * * @return stock name */ public String getName() { return name; } /** * set...
This code it's not working, fix it for me please #include <iostream> using namespace std; class...
This code it's not working, fix it for me please #include <iostream> using namespace std; class People {    string name;    double height; public:    void setName(string name)    {        this->name = name;    }    void setHeight(double height)    {        this->height = height;    }    double getHeight() {        return height;    }    string getName()    {        return name;    } }; int main() {    const int size...
Provide A UML for the Following CODE public class Employee{ public String strName, strSalary; public Employee(){...
Provide A UML for the Following CODE public class Employee{ public String strName, strSalary; public Employee(){    strName = " ";    strSalary = "$0";    } public Employee(String Name, String Salary){    strName = Name;    strSalary = Salary;    } public void setName(String Name){    strName = Name;    } public void setSalary(String Salary){    strSalary = Salary;    } public String getName(){    return strName;    } public String getSalary(){    return strSalary;    } public String...
Sort by the following (name, address, dependent and gender) of these and ask the user which...
Sort by the following (name, address, dependent and gender) of these and ask the user which field to sort by !. this mean the following java must sort by address if we need, by name , by dependent , and by gender it depend on the following java it must have an option which we need to sort. please i need your help now, you just add the sorting on the following java. // Use a custom comparator. import java.io.BufferedReader;...
Write an application that stores the following nine integers in an array: 10, 15, 19, 23,...
Write an application that stores the following nine integers in an array: 10, 15, 19, 23, 26, 29, 31, 34, 38. Display the integers from first to last, and then display the integers from last to first. ----------------------------------------------- public class NineInts {     public static void main (String args[]) {         // Write your code here     } } ------------------------ Please use JAVA