Thursday, December 15, 2011

JAVA program help! Please

I'm suppose to create a program using BankAccount and BankAccountTester classes, and am suppose to be able to create an account with a specified opening balance, make bank deposits, withdrawls and check balance.





My program compiles correctly, but it doesn't run, I am not sure what else I need to do to make sure that it runs correctly and accurately does all four tasks?








This is what I have so far:





public class BankAccount {





double balance;


String name;





public BankAccount( String name, double balance ) {


name = name;


balance = balance;


}





public void deposit(double amount) {


balance *= amount;


}





public void withdraw( double amount ) {


balance -= amount;


}





public void setBalance( double b ) {


b = balance;


}





public double getBalance() {


return balance;


}





public String toString() {


return "Name: " name " " balance;


}


}




















import javax.swing.*;





public class BankAccountTester {





public static final int QUIT = 0;


public static final int DEPOSIT = 1;


public static final int WITHDRAW = 2;


public static final int INQUIRY = 3;





public static void main(String[] s) {





String lName = JOptionPane.showInputDialog( "Enter last name" );


String fName = JOptionPane.showInputDialog( "Enter first name" );


double openingBalance = Double.parseDouble( JOptionPane.showInputDialog( "Enter opening balance" ) );


String name = lName ", " fName;


BankAccount a = new BankAccount ( name, openingBalance );





Object[] options = {"Quit", "Deposit", "Withdraw", "Balance Inquiry"};


int chosenOption = 999; // A garbage value to get me into the while loop the first time.





do {





chosenOption = JOptionPane.showOptionDialog( null, "What transaction would you like to do?", "Transaction",


JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0] );





switch ( chosenOption ) {


case QUIT:


// Do nothing, will fall out of loop;


break;





case DEPOSIT:


double dep = Double.parseDouble( JOptionPane.showInputDialog( "Enter Amount of Deposit" ) );


a.deposit( dep );





case WITHDRAW:


double wd = Double.parseDouble( JOptionPane.showInputDialog( "Enter Amount of Withdrawal" ) );


a.deposit( wd );


break;





case INQUIRY:


JOptionPane.showMessageDialog( null, "Balance = " a.getBalance() );


break;





default:


JOptionPane.showMessageDialog( null, "Invalid Option" );


break;


}








} while ( chosenOption %26gt; 0 );





}


}








please help


thanks|||Hello,





This code here will not compile. Why do you think that it does?





Here are three errors my compiler found, all are string concatenation mistakes:


"Balance = " a.getBalance() should be: ("Balance = "+a.getBalance())





String name = lName ", " fName; should be: String name = lName+", "+fName;





return "Name: " name " " balance; should be: return "Name: "+name+" "+balance;





Remember, use the '+' sign to concat (aka combine) strings.|||your first code uses 2 variables with the same name


public BankAccount( String name, double balance ) {


name = name;


balance = balance;


}


either change parameter name or use this.name=name


also method deposit - need + not *


public void deposit(double amount) {


balance *= amount;


}

What if my Annuity was paid for with AFTER-TAX dollars?

Assume I am over 60 but under 95. I am looking to withdraw my annuity over a given time, say 10 years, but the money used to initiate the annuity and deposits (the principle) were all paid with after-tax dollars. What will I have to do to ensure that I do not have to pay taxes on this portion of my withdrawal again??





I am actually asking this question on behalf of another, in case that was not already apparent.|||You're in luck. I'm in the annuity business. When your principal in an annuity is post tax dollars, whatever portion of your annuitized payments is return-of-principal is not taxed. Whatever portion of it is earnings or gain on the principal is taxed unless you have a Roth Annuity (typically created by opening a Roth IRA, then using that as a rollover vehicle to open the annuity, in which case all the proceeds are tax free when you annuitize).





As with most retirement vehicles, they're designed to have payments begin after age 59 and 1/2. If you begin receiving payments prior to that, the tax and penalty situations are different than what I described above.





Summary:


1. Wait till at least age 59.5 to begin receiving payment (which you are).





2. If it's a standard annuity, opened with after tax dollars, the payments received will only be partially taxed. The portion of payments that are a return of principal are not taxed, but the gains are. After all the principal is returned, the entire payment is gain and therefore taxable.





Essentially you will not have to pay the tax on the already-taxed principal again.|||It should be documented in the annuity as to what types of funds were allocated to it. Best bet is to talk to the institution thats holding it to see what the local and federal reporting requirements are and what types of documentation they can provide to you. If they are no help then any tax preparer should be able to help you out.





Pre or post-tax funding is something that is very spelled out at the get go.





Now if pre-tax funds were intermingled with it then it can get quite complicated but shouldn't be anything your average tax preparer couldn't help you with.|||Although the above answers are correct, simply stated you don't need to worry about it. The insurance company will send you a 1099 form each year indicating the amount that is return of principal and the amount that is earned interest. Only the interest is taxable.|||Do you already have the annuity? If so you need to contact the company you got it from and make sure they know that you have already paid taxes on this money because you do not want to have to pay taxes again on it. They should be able to clarify this for you. It should be specified in the contract so they know how it is to be distributed to you. One thing be sure and look at as far as speading the payments out, there are several ways you can elect to do it but be sure it is where the money is left to your benificiary if that is your desire because there is one particular way it is distributed over the period of time but when you die that ends the annuity. I hope this helps answer you questions.


You really need someone qualified as financial advisor to give you the best help. You may want to ask a friend or someone who knows a reputable person. Good luck to you.

Can a soon to be ex husband go into your joint account and withdraw money even though the wife used it more?!!?

My friend left her husband this past Friday. They got into huge argument and this one one of several they'd had recently, she packed up their 3 kids and left to go stay with her parents. Well she got her tax return back and it was deposited into her joint account she has with him, and although she used the account primarily for her job to do direct deposit, he never put any money into the account and didn't spend out of it, even though he would never take his name off the account. He has another account with another bank and uses that one for his job. Anyways, after she left, she was still getting settled into her parents house, when she decides to go and pick up some things form the store, she goes there and tries to use her debit card, it was declined. Later on, she found out that he had done withdrew all her money except 50 dollars . He took about 3 g's from her. Can he do this? This was her tax money that she received from her job, since she filed separate and he did too. They were separated at the time and both them filed separate, head of house hold because this time he moved out, then they reconciled, now this!|||Of course he can do this, and it's perfectly legal. His name was on the account. If it was a work account, why on earth would he have access to it? She's going to have to prove in court that it was indeed a work account, and that he had never used it before. She still may not get the funds back though. That's for a judge to decide. Tell her to get an attorney.|||Absolutely, he has legal rights to access any account that still has his name on it.





A judge may stipulate that he return half of it or more in a divorce settlement, but he has violated no laws.|||Absolutely, it was a joint account, he had every right to access it and withdraw money from it.|||yes, its in his name as well as in hers, so their marital status does not matter|||Yes.|||key word " joint " account so yes.|||Its a joint account, they both "own" it equally. At this point it comes down to who ever gets to the money first.|||yes.








if his name is on the account he has every right to take money out, or even close it if he feels like.

Can I withdraw my PF from RPFC, if its being deposited there for last 34 months? If yes, what's the procedure.

I am working with an MNC in Rajasthan, my Provident Fund is being deducted from my salary and being deposited in Rajasthan Provident Fund Corporation since October 2005 (for 34 months). Can I withdraw these funds from there as I am moving out of the country for a long time. If yes, what is the process of going for it.|||Use the appropriate form for claiming Provident Fund Pension, withdrawal benefit/scheme certificate, Employees' Deposit Linked Insurance benefit, etc. as given below :-








Form-19 : To claim final settlement of Provident Fund by a member.





AND





Form-10-D : To claim pension. (In duplicate : If within state, In triplicate : If outside state.)





OR





Form-10-C : To claim withdrawal benefit/scheme certificate under Employees' Pension Scheme '95.





Ensure that all columns of the application are filled completely.








Information in the application form relating to name, a/c no. should agree with the details available with Employees' Provident Fund Organization; which were furnished by the employer at the time of enrolling to Provident Fund.








Application should be signed by the member/claimant.








It should be attested by the former employer. In case attestation by the former employer is not possible, it should be got attested by any other authorized official specified with application form.








Application for final settlement can be sent by a member on completion of 2 months from the date of leaving service, if the reason for leaving service is other than superannuation, medical ground, retrenchment and V.R.S./ Female members getting married etc.








Desired mode of payment can be given legibly, if the amount involved is more than Rs. 2000/-. The amount will sent by deposit in payees' bank a/c. To facilitate this, Bank a/c no., name and address of the bank should be furnished. An advance stamped receipt should also accompany this application.





After all these formalities submit it to concerned EPFO Office.

Microsoft Visual Studios 2008 - how to save?

I'm working on creating an ATM account using Microsoft VS 2008, that includes a login number, an "Amount" label, "Balance" label, and buttons: Deposit, Withdraw, and Logout. I am having a hard time understanding how I can logout of the account number while saving the balance, so when one logs back in, the balance remains. I am using "Getting Started with Microsoft VS 2008" by Michael Halvorson as a reference, but am missing just one important step.





Is anyone able to point me in the right direction as to how I can figure this out?|||In a real wold ATM, the account balance would be saved in a database (along with login id).


Not sure how this book is handling saving the data, but other options would be: save to a file of some sort, or save to memory(it would all go away when you exit the program).





But in any case, someone logging in or out doesn't change the data that is stored about their account. Logging out only means that you don't accept any more input from the user until they log in again. The data doesn't just disappear because you log out.

Depositing Cash into Bank of America Checking Account?

I have a question. I have had a checking account for quite some time already. I always deposited checks into the atm. I never have deposited cash before when i go to a teller. I have withdrawn many times though. When i withdraw from bank of america at the teller, i have to swipe my debit card and then type my 6 digit pin.








Do i HAVE to fill out a deposit slip when depositing cash at bank of america? Or can i just give the teller the cash and tell them how much it is and swipe my debit card?|||If you go to a Bank of America ATM Machine, they typically give you the option to deposit cash or a check, and if you choose on cash, a slide will open and you just place the cash inside, the slide shuts and it counts your money for you and puts it onto your account. That's the experience I have had with it, I to have Bank of America and thats how I typically deposit cash. It takes upto 24 hours for it to show up on your account though.|||Deposit slip

Depositing Cash into Bank of America Checking Account?

I have a question. I have had a checking account for quite some time already. I always deposited checks into the atm. I never have deposited cash before when i go to a teller. I have withdrawn many times though. When i withdraw from bank of america at the teller, i have to swipe my debit card and then type my 6 digit pin.








Do i HAVE to fill out a deposit slip when depositing cash at bank of america? Or can i just give the teller the cash and tell them how much it is and swipe my debit card?|||The deposit slip keeps a record of your money. You want that. So does BofA. Fill one out.



But you are correct. If the ATM accepts your cash and card, the teller should too. You will get a receipt for the deposit as your proof.