Skip to content

Instantly share code, notes, and snippets.

@jaggy
Created September 17, 2014 16:34
Show Gist options
  • Save jaggy/b83d5a0f6785c049b6bd to your computer and use it in GitHub Desktop.
Save jaggy/b83d5a0f6785c049b6bd to your computer and use it in GitHub Desktop.
public class Test
{
public static void main (String[] args)
{
int currentBalance = 50000;
int withdrawalAmount = 5000;
boolean cashIsDivisibleByOneHundredBills = (withdrawalAmount % 100 == 0);
boolean doesNotExceedBalance = (withdrawalAmount < currentBalance);
boolean isWithdrawable = (cashIsDivisibleByOneHundred && doesNotExceedBalance);
if (isWithdrawable) {
int balance = currentBalance - withdrawalAmount;
int oneThousandBills = withdrawalAmount / 1000;
withdrawalAmount = withdrawalAmount % 1000;
int fiveHundredBills = withdrawalAmount / 500;
withdrawalAmount = withdrawalAmount % 500;
int twoHundredBills = withdrawalAmount / 200;
withdrawalAmount = withdrawalAmount % 200;
int oneHundredBills = withdrawalAmount / 100;
withdrawalAmount = withdrawalAmount % 100;
String name = "Ma. Vina A. Francisco";
System.out.println(name);
System.out.println("Date today is:");
System.out.println("Balance:" + currentBalance);
System.out.println("Amount Withdrawed:" + actWitAmt);
System.out.println("1000's : " + oneThousandBills);
System.out.println("500's : " + fiveHundredBills);
System.out.println("200's : " + twoHundredBills);
System.out.println("100's : " + oneHundredBills);
System.out.println("New Current Balance is " + balance + ".");
} else {
System.out.println("The input is invalid");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment