gpbarga's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
7 (0.01 per day)
Joined:
29-April 12
Profile Views:
100
Last Active:
User is offline Mar 29 2014 12:10 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   gpbarga has not set their status

Posts I've Made

  1. In Topic: Need help with Bank account program

    Posted 27 Mar 2014

    Oh I must've missed that when I copied, yes there is suppose to be a closing bracket at the end of account. I have been working on this program but what's even weirder is that the code is actually working when I call it using different methods.
    For example I've been writing some code to test this method
    public static void main(String[] args) throws Exception 
            {
                
    		Scanner scan = new Scanner(System.in);
            
    		Bank b = new Bank();
    		b.openCheckingAccount();
    		b.openSavingsAccount();
    		b.openCheckingAccount();
    		b.openSavingsAccount();
    		
    		b.deposit(2, 50);		
    		double x = b.getBalance(2);
    		System.out.println(x);
    		
    		b.withdraw(2, 25);
    		double x2 = b.getBalance(2);
    		System.out.println(x2);
    }
    


    b.deposit(2, 25); -- what this does is it goes to the account id 2, and deposits the money in there.

    So what I don't get is why the test code is not working for it?
  2. In Topic: Need help with Bank account program

    Posted 27 Mar 2014

    Exception in thread "main" java.lang.Exception: cannot find this
    	at pa1.Bank.findAccount(Bank.java:95)
    	at pa1.Account.main(Account.java:112)
    
    


    this is what I got for my output..
  3. In Topic: Need help with Bank account program

    Posted 27 Mar 2014

    I am just trying to figure out why this method

       public Account findAccount(int number) throws Exception
       {       
           for( Account account : this.list)
           {     
               try{
               if(account.getNumber()== number)
               {
                   return account;
               }
               }
               catch (Exception e){};
               
           }             
           throw new Exception();
       }
               
    


    is not passing this test

    @Test
    	public void findAccount() {
    		Bank b = new Bank();
    
    		// Open a bunch of accounts
    		b.openCheckingAccount();
    		b.openSavingsAccount();
    		b.openSavingsAccount();
    		b.openCheckingAccount();
    		
    		// Save the account number of one of them
    		int accountNum = b.openCheckingAccount();
    
    		// Open a bunch more
    		b.openCheckingAccount();
    		b.openSavingsAccount();
    		b.openSavingsAccount();
    		b.openCheckingAccount();
    		
    		try {
    			// We should be able to find that account
    			Account a = b.findAccount(accountNum);
    			assertEquals(accountNum, a.getNumber());
    		} catch(Exception e) {
    			fail("Failed to find account");
    		}
    	}
    


    I find the logic correct but I don't understand why it is failing
  4. In Topic: Problem with IO stream.

    Posted 12 Dec 2012

    thanks for the quick reply!, I made the changes and the output is:


    Please enter the name of the existing file:
    old.txt
    Please enter the name of the new file:
    new.txt
    Choose from the following choices:
    1 - Exit the program.
    2 - Overwrite the existing file
    3 - Enter a new name for the file
    Enter a number:
    3
    Enter a new name for the new file:
    java.io.FileNotFoundException: (No such file or directory)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:212)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:104)
    at java.io.PrintWriter.<init>(PrintWriter.java:184)
    at project4.Project4.main(Project4.java:79)

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

gpbarga hasn't added any friends yet.

Comments

gpbarga has no profile comments yet. Why not say hello?