I'm trying to do some consolidation but I'm not sure on the specific rules of consolidation so I'm having A LOT of difficulty on it. Here's what I'm trying to do.
Write a program that prompts for and reads in three names and creates an account with an initial balance of $100 for each. Print the three accounts, then close the first account and try to consolidate the second and third into a new account. Now print the accounts again, including the consolidated one if it was created.
I'm having difficulty with closing the first account then Consolidating :(. Here's my code so far with no errors so far.

//***********************************************************
// TestAccounts1
// A simple program to test the numAccts method of the
// Account class.
//***********************************************************
import java.util.Scanner;

public class TestConsolidation
{
    public static void main(String[] args)
    {

        String name1;
        String name2;
        String name3;
        double balance = 100.00;
        int balance1;
        int balance2;
        int balance3;

        //declare and initialize Scanner object
        String message;
        Scanner scan = new Scanner (System.in);

        //Prompt for and read in the names
        System.out.println ("What is the first name? ");
        name1 = scan.next();

        message = scan.nextLine();
        //balance = balance1;

        System.out.println ("The first name is: \"" + name1 + "\"");
        System.out.println("The balance for this acoount is:" +balance);

        System.out.println ("What is the second name? ");
        name2 = scan.next();

        message = scan.nextLine();

        System.out.println ("The second name is: \"" + name2 + "\"");
        System.out.println("The balance for this acoount is:" +balance);

        System.out.println ("What is the third name? ");
        name3 = scan.next();

        message = scan.nextLine();

        System.out.println ("The first name is: \"" + name3 + "\"");
        System.out.println("The balance for this acoount is:" +balance);


   

    }
}

Recommended Answers

All 7 Replies

What is a consolidated account? Just an account under both names? What do you have to do to 'make an account consolidated'?

What is a consolidated account? Just an account under both names? What do you have to do to 'make an account consolidated'?

Thats one of my problems. I have no clue. I can't find anything useful in my book or online. What about the second part? How would I close the first account?

Again, that depends on what you mean by 'closing an account'. Typically you'd close an account by removing all the money from it, i.e. withdrawing all money from your bank account, then just deleting it or somehow marking it as closed. But we are just programmers, if you need help with implementation or errors that's fine, but I doubt you'll find much help on how to interpret your project's requirements. Is this for a class? If so speak to the professor.

Again, that depends on what you mean by 'closing an account'. Typically you'd close an account by removing all the money from it, i.e. withdrawing all money from your bank account, then just deleting it or somehow marking it as closed. But we are just programmers, if you need help with implementation or errors that's fine, but I doubt you'll find much help on how to interpret your project's requirements. Is this for a class? If so speak to the professor.

I'm trying to do some form of account.close();. No matter where I put it in my program it won't work :(.

Yes but what is the close method supposed to do?

Close out a public void close().

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.