import javax.swing.*;
import java.math.*;
import java.text.*;
import java.util.*;
public class Subway{
public static void main(String[] args){
DecimalFormat df = new DecimalFormat("#.##");
String title1 = "How Many Monies?";
String title2 = "This Many Monies!";
String title3 = "Cash Drop Helper";
final double minus = 200;
//Gather Variables
String userInput = JOptionPane.showInputDialog(null, "How many 100's are there?", title1, JOptionPane.QUESTION_MESSAGE);
double hundred = Double.parseDouble(userInput);
hundred = hundred * 10000;
userInput = JOptionPane.showInputDialog(null, "How many 50's are there?", title1, JOptionPane.QUESTION_MESSAGE);
double fifty = Double.parseDouble(userInput);
fifty = fifty * 5000;
userInput = JOptionPane.showInputDialog(null, "How many 20's are there?", title1, JOptionPane.QUESTION_MESSAGE);
double twenty = Double.parseDouble(userInput);
twenty = twenty * 2000;
userInput = JOptionPane.showInputDialog(null, "How many 10's are there?", title1, JOptionPane.QUESTION_MESSAGE);
double ten = Double.parseDouble(userInput);
ten = ten * 1000;
userInput = JOptionPane.showInputDialog(null, "How many 5's are there?", title1, JOptionPane.QUESTION_MESSAGE);
double five = Double.parseDouble(userInput);
five = five * 500;
userInput = JOptionPane.showInputDialog(null, "How many 1's are there?", title1, JOptionPane.QUESTION_MESSAGE);
double one = Double.parseDouble(userInput);
one = one * 100;
userInput = JOptionPane.showInputDialog(null, "How many quarters are there?", title1, JOptionPane.QUESTION_MESSAGE);
double quarter = Double.parseDouble(userInput);
quarter = quarter * 25;
userInput = JOptionPane.showInputDialog(null, "How many dimes are there?", title1, JOptionPane.QUESTION_MESSAGE);
double dime = Double.parseDouble(userInput);
dime = dime * 10;
userInput = JOptionPane.showInputDialog(null, "How many nickels are there?", title1, JOptionPane.QUESTION_MESSAGE);
double nickel = Double.parseDouble(userInput);
nickel = nickel * 5;
userInput = JOptionPane.showInputDialog(null, "How many pennies are there?", title1, JOptionPane.QUESTION_MESSAGE);
double penny = Double.parseDouble(userInput);
//Add Variables
double dollars = hundred + fifty + twenty + ten + five + one;
double cents = quarter + dime + nickel + penny;
double total = dollars + cents;
total = total / 100;
JOptionPane.showMessageDialog(null, "Total is $" + total, title2, JOptionPane.INFORMATION_MESSAGE);
//Correct all the variables
hundred = hundred / 100;
fifty = fifty / 100;
twenty = twenty / 100;
ten = ten / 100;
five = five / 100;
one = one / 100;
quarter = quarter / 100;
dime = dime / 100;
nickel = nickel / 100;
penny = penny / 100;
//Display each amount
final String[] eachAmt = {"Money in hundreds: $" + hundred, "Money in fifties: $" + fifty, "Money in twenties: $" + twenty, "Money in tens: $" + ten, "Money in fives: $" + five, "Money in ones: $" + one, "Money in quarters: $" + df.format(quarter), "Money in dimes: $" + df.format(dime), "Money in nickels: $" + df.format(nickel), "Money in pennies: $" + df.format(penny)};
JOptionPane.showMessageDialog(null, new JList(eachAmt), title3, JOptionPane.INFORMATION_MESSAGE);
//Subtract 200
double TAKE = total - minus;
String takeOut = "Take out " + TAKE + "\nPut it in an envelope." + "\nDrop it in the red safe.";
JOptionPane.showMessageDialog(null, takeOut, title3, JOptionPane.INFORMATION_MESSAGE);
//what bills
int take = TAKE;
double tHundreds = 0;
double tFifties = 0;
double tTwenties = 0;
double tTens = 0;
double tFives = 0;
double tOnes = 0;
if (take >= 100){
tHundreds = take / 100;
take = take % 100;
}
if (take >= 50){
tFifties = take / 50;
take = take % 50;
}
if (take >= 20){
tTwenties = take / 20;
take = take % 20;
}
if (take >= 10){
tTens = take / 10;
take = take % 10;
}
if (take >= 5){
tFives = take / 5;
take = take % 5;
}
tOnes = take;
final String[] bills = {"Take Out" + "\n" + tHundreds + " Hundreds" + "\n" + tFifties + " Fifties" + "\n" + tTwenties + " Twenties" + "\n" + tTens + " Tens" + "\n" + tFives + " Fives" + "\n" + tOnes + " Ones"};
JOptionPane.showMessageDialog(null, bills, title3, JOptionPane.INFORMATION_MESSAGE);
}
}