import java.util.Scanner;
public class Kiosk {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(
System.in);
Converter dm = new Converter();
System.out.println("Welcome, Guest! Thank you for using Jacob *********'s Cash-for-Change Service!");
System.out.println();
String userInput = "y";
do
{
String input;
System.out.println("Our transaction has begun. Please deposit the change you wish to exchange.");
do
{
System.out.println(">");
input = in.nextLine();
input.toLowerCase();
if(input.equals("done"))
{
break;
}
else
{
String[] parts = input.split(" ");
if(parts.length !=2 || input.equals("done"))
{
System.err.println("Invalid Input. Please begin a new transaction.");
userInput = "n";
input = "done";
}
else
{
String part1 = parts[0];
String part2 = parts[1];
part2.toLowerCase();
int coinAmount = Integer.parseInt(part1);
if(part2.equals("quarter") || part2.equals("quarters"))
{
dm.addQuarters(coinAmount);
}
else if(part2.equals("dime") || part2.equals("dimes"))
{
dm.addDimes(coinAmount);
}
else if(part2.equals("nickel") || part2.equals("nickels"))
{
dm.addNickels(coinAmount);
}
else if(part2.equals("penny") || part2.equals("pennies"))
{
dm.addPennies(coinAmount);
}
else
{
System.err.println("Invalid input. Please try again.");
}
dm.getCollectedFees();
}
}
}while(input != "done");
dm.getVoucher();
System.out.println("The current transaction has ended. Would you like to make another? Please enter 'y' or 'n'.");
userInput =
in.next();
while(!userInput.equals("y") && !userInput.equals("n"))
{
System.err.println("Invalid input. Please try again.");
userInput =
in.next();
}
in.nextLine();
}while(userInput.equals("y"));
double moneyStolen = dm.getCollectedFees();
System.out.printf("Thank you for throwing money our way! Instead of going to a bank to get the same service for free, you have given us $%.2f. We appreciate your business!", moneyStolen);