Working on a simple banking program and it doesn't compile. Worked perfectly when everything was in main, then i was told to divide into methods( where everything went wrong ).
The errors im getting are:
C:\Users\DJ3\Desktop\School\Minilab5.java:30: illegal start of expression
}
^
C:\Users\DJ3\Desktop\School\Minilab5.java:67: illegal start of type
switch (userChoice)
^
C:\Users\DJ3\Desktop\School\Minilab5.java:67: <identifier> expected
switch (userChoice)
^
C:\Users\DJ3\Desktop\School\Minilab5.java:69: orphaned case
case 1:
^
4 errors
Process completed.
import java.util.Scanner;
public class Minilab5
{
public static void main (String[] args)
{
Minilab5 banker = new Minilab5 ();
banker.dispatcher ();
}
void dispatcher ()
{
Scanner in = new Scanner(System.in);
int userChoice;
boolean quit = false;
float balance = 0f;
do
}
{
System.out.println("1. Deposit money");
System.out.println("2. Withdraw money");
System.out.println("3. Check balance");
System.out.print("0. To quit");
userChoice = in.nextInt();
}
public static void deposit()
{
float amount;
System.out.print("Amount to deposit: ");
amount = in.nextFloat();
if (amount <= 0)
System.out.println("Cannot deposit negative amounts.");
else
{
balance += amount;
System.out.println("$" + amount + " has been deposited.");
}
}
public static void withdraw()
{
System.out.print("Amount to withdraw: ");
amount = in.nextFloat();
if (amount <= 0 || amount > balance)
System.out.println("Insufficient Funds.");
else
{
balance -= amount;
System.out.println("$" + amount + " has been withdrawn.");
}
}
switch (userChoice)
{
case 1:
deposit();
break;
case 2:
withdraw();
break;
case 3:
System.out.println("Your balance: $" + balance);
break;
case 0:
quit = true;
break;
default:
System.out.println("Incorrect choice.");
break;
}
{
while (!quit);
System.out.println("Have a nice day");
}
}
Im sure the issue is with the braces but i cant seem to find it