I am working on an ATM machine project for my college class. It's in its early stages but here what I have so far.
/**
*
* @author Ty
*/
import java.util.Scanner;
public class Main {
private double currentBal =1000;
Scanner input = new Scanner(System.in);
public void mainMenu(){
int selection;
System.out.print("Welcome to the Automated Teller Machine!\n");
System.out.println("Select from the following menu options below:\n");
System.out.println("========================");
System.out.println("| [1] Check Balance |");
System.out.println("| [2] Withdrawal |");
System.out.println("| [3] Deposit |");
System.out.println("| [4] Exit |");
System.out.println("========================");
System.out.print("Please select your option now: ");
selection =input.nextInt();
switch (selection){
case 1:
viewBalance();
break;
case 2:
withdrawFunds();
break;
case 3:
depositFunds();
break;
case 4:
System.out.println("Thank you for using ATM! \n Goodbye! \n");
}
}
public void viewBalance() {
int selection1;
System.out.println("You have selected Balance.\n");
System.out.println("\t-- Your Current Balance is:$ " + currentBal);
System.out.println("Return to main menu? \n [1] for YES \n");
selection1 =input.nextInt();
switch (selection1){
case 1:
mainMenu();
break;
}
}
public void withdrawFunds() {
int withdrawSelection;
System.out.println("Amount to withdraw: ");
System.out.println("[1] - $20");
System.out.println("[2] - $40");
System.out.println("[3] - $50");
System.out.println("[4] - $100");
System.out.println("[5] - MAIN MENU");
System.out.print("Please select your option now: ");
withdrawSelection =input.nextInt();
switch (withdrawSelection){
case 1:
accountWithdraw(20);
mainMenu();
break;
case 2:
accountWithdraw(40);
mainMenu();
break;
case 3:
accountWithdraw(50);
mainMenu();
break;
case 4:
accountWithdraw(100);
mainMenu();
break;
case 5:
mainMenu();
break;
}
}
public void accountWithdraw(int withdrawFunds){
currentBal = currentBal -withdrawFunds;
System.out.println("Please take your funds.");
}
public void depositFunds(){
int addSelection;
System.out.println("Amount to deposit: ");
System.out.println("[1] - $20");
System.out.println("[2] - $40");
System.out.println("[3] - $50");
System.out.println("[4] - $100");
System.out.println("[5] - MAIN MENU");
System.out.print("Please select your option now: ");
addSelection =input.nextInt();
switch (addSelection){
case 1:
accountAdd(20);
mainMenu();
break;
case 2:
accountAdd(40);
mainMenu();
break;
case 3:
accountAdd(50);
mainMenu();
break;
case 4:
accountAdd(100);
mainMenu();
break;
case 5:
mainMenu();
break;
}
}
public void accountAdd (int depositFunds){
currentBal = currentBal +depositFunds;
System.out.println("Thank you.");
}
public static void main(String[] args) {
// TODO code application logic here
}
}
For some reason it won't compile correctly in NetBeans because I get this:
deps-jar:
Created dir: C:\Users\Ty\Documents\NetBeansProjects\atmLong\build
Updating property file: C:\Users\Ty\Documents\NetBeansProjects\atmLong\build\built-jar.properties
Created dir: C:\Users\Ty\Documents\NetBeansProjects\atmLong\build\classes
Created dir: C:\Users\Ty\Documents\NetBeansProjects\atmLong\build\empty
Compiling 1 source file to C:\Users\Ty\Documents\NetBeansProjects\atmLong\build\classes
compile:
Created dir: C:\Users\Ty\Documents\NetBeansProjects\atmLong\dist
Not copying the libraries.
Building jar: C:\Users\Ty\Documents\NetBeansProjects\atmLong\dist\atmLong.jar
To run this application from the command line without Ant, try:
java -jar "C:\Users\Ty\Documents\NetBeansProjects\atmLong\dist\atmLong.jar"
jar:
BUILD SUCCESSFUL (total time: 0 seconds)
My past projects have allowed me to run the program in NetBeans to test it out... anyone know what I am doing wrong? Any information would be greatly helpful.
Thanks!
Climber Ty