9/23/10



"WithDraw Deposit" - Java Code

9/23/2010

import java.util.Scanner;


public class WithDrawDeposit{


public static void main (String[] args){


Scanner input = new Scanner(System.in);


double transact;
double balance = 20000;
double finalBal = 0;


System.out.println("Your current balance is Php 20,000.00");
System.out.println("A Postive number means Deposit");
System.out.println("A Negative number means Withdraw");
System.out.println("Press 0 to end transaction.\n\n");


here:


do{


System.out.print("Enter amount to transact: ");
transact = input.nextDouble();


if(transact==0) {
System.out.println("Program will now exit...\n");
System.out.println("Current Balance now: " + "Php " + balance);
System.exit(0);
}
else if(transact>0){
finalBal = balance + transact;
System.out.println("Current Balance: " + "Php " + finalBal);
}
else{
if(-(transact)>finalBal){
System.out.println("Insufficient Funds!");
continue here;
}
finalBal = balance + (transact);
System.out.println("Current Balance: " + "Php " + finalBal);


}


balance = finalBal;


}while(transact<0||transact>0);


}




}



Your thoughts about this post? Leave a commment now.

Posted by

AndyFGo : A place for Pinoy Music News. Lyrics. Music Videos. Pinoy Movie/Foreign Trailers. OPM.

 

© 2013 andyfgo. All rights reserved. Designed by Templateism. Powered by Blogger
Protected by Copyscape DMCA Takedown Notice Violation Search

Back To Top