lbgladson's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
Members
Active Posts:
43 (0.05 per day)
Joined:
04-February 12
Profile Views:
493
Last Active:
User is offline Sep 29 2012 12:33 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   lbgladson has not set their status

Posts I've Made

  1. In Topic: Linked List

    Posted 18 Sep 2012

    I looked at another program I had written with Linked Lists and decided to use an iterator to write the program. Now I have the below code that is printing the list but not reversing it.

    import java.util.LinkedList;
    import java.util.ListIterator;
    
    import javax.swing.text.html.HTMLdocument.Iterator;
    
    public class Reverse {
    	public static void reverse(LinkedList<String> staff) {
    
    		ListIterator<String> staffIterator = staff.listIterator();
    
    		LinkedList<String> reversed = new LinkedList<String>();
    		while (staffIterator.hasPrevious()) {
    			reversed.add(staffIterator.previous());
    		}
    	}
    }
    
    
  2. In Topic: Sorting Arrays

    Posted 9 Sep 2012

    Using the getValue() worked. Thank you! I had tried that attempt earlier in writing my code and had many more problems and did not even think about using that again.
  3. In Topic: Sorting Arrays

    Posted 9 Sep 2012

    When I try to change it to < I get the error message that the operator is undefined for the argument and I'm not sure what I would need to do to make that not an error.
  4. In Topic: ArrayLists

    Posted 21 Aug 2012

    I have been able to get past the point of entering the information into each bank account. Now I am stuck on how to get the withdraw and deposit amount from the user to the method and then the new balance to the arraylist. Below is what I have
    public class BankAccount {
    
    	private int accountId;
    	private String name;
    	private double balance;
    
    	public BankAccount(int accountID, String personName, double initialBalance) {
    		accountId = accountID;
    		name = personName;
    		balance = initialBalance;
    	}
    
    	public void deposit(double amount) {
    		double newBalance = balance + amount;
    		balance = newBalance;
    
    	}
    
    	public void withdraw(double amount) {
    		double newBalance = balance - amount;
    		balance = newBalance;
    
    	}
    
    	public int getAccountId() {
    		return accountId;
    	}
    
    	public String getName() {
    		return name;
    	}
    
    	public double getBalance() {
    		return balance;
    	}
    	
    	public String toString() {
    		return "BankAccount:" + " " + accountId +  " " + name +  " " + balance;
    	}
    }
    
    


    import java.util.ArrayList;
    import java.util.Scanner;
    
    public class BankAccountTester {
    
    	public static void main(String[] args) {
    
    		int n = 0;
    
    		ArrayList<BankAccount> bankAccounts = new ArrayList<BankAccount>(n);
    
    		Scanner in = new Scanner(System.in);
    		System.out.print("How many accounts are you going to enter? ");
    		n = in.nextInt();
    
    		for (int i = 0; i < n; i++) {
    
    			System.out.println("Enter the account ID: ");
    			int accountId = in.nextInt();
    
    			System.out.println("Enter the account name: ");
    			String name = in.next();
    
    			System.out.println("Enter the account balance: ");
    			double balance = in.nextDouble();
    
    			bankAccounts.add(new BankAccount(accountId, name, balance));
    
    		}
    
    		for (BankAccount balance : bankAccounts) {
    			
    						
    			System.out.print("Enter the withdraw amount:");
    			double withdraw = in.nextDouble();
    			bankAccounts.withdraw(balance);
    			
    			
    			System.out.print("Enter the deposit amount:");
    			double deposit = in.nextDouble();
    			
    				
    			
    
    		}
    		
    		for (int i = 0; i < n; i++) {
    			 System.out.println(bankAccounts.toString());
    		}
    
    	}
    }
    
    
  5. In Topic: ArrayLists

    Posted 21 Aug 2012

    I thought about having an empty constructor but the assignment says to include accountId, name and initial balance as parameters for the constructor.

My Information

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

Contact Information

E-mail:
Click here to e-mail me

Friends

lbgladson hasn't added any friends yet.

Comments

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