-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSimpleJavaBanking
More file actions
66 lines (60 loc) · 2.7 KB
/
Copy pathSimpleJavaBanking
File metadata and controls
66 lines (60 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import java.util.Scanner;
public class Lab6C {
public static void main(String[] args) {
int menu;
int deposit;
int withdraw;
int dollarAmount = 1000;
String mainMenu = null;
System.out.println("Welcome!\nYou have $1000 in your account.\n");
Scanner input = new Scanner(System.in);
do {
System.out.println("Menu\n0 - Make a deposit\n1 - Make a withdrawal\n2 - Display account value\n");
System.out.print("Please make a selection: ");
menu = input.nextInt();
switch (menu) {
case 0:
System.out.print("How much would you like to deposit? : ");
deposit = input.nextInt();
dollarAmount = dollarAmount + deposit;
System.out.println("Your current balance is $" + dollarAmount);
System.out.print("Would you like to return to the main menu (Y/N)? : ");
mainMenu = input.next();
if (mainMenu.equals("N"))
{
System.out.println("Thank you for banking with us!");
}
break;
case 1:
System.out.print("how much would you like to withdraw? : ");
withdraw = input.nextInt();
dollarAmount = dollarAmount - withdraw;
System.out.println("Your current balance is $" + dollarAmount);
System.out.print("Would you like to return to the main menu (Y/N)? : ");
mainMenu = input.next();
if (mainMenu.equals("N"))
{
System.out.println("Thank you for banking with us!");
}
break;
case 2:
System.out.println("Your current balance is $" + dollarAmount);
System.out.print("Would you like to return to the main menu (Y/N)? : ");
mainMenu = input.next();
if (mainMenu.equals("N"))
{
System.out.println("Thank you for banking with us!");
}
break;
default:
System.out.println("Invalid entry, please try again.");
System.out.print("Would you like to return to the main menu (Y/N)? : ");
mainMenu = input.next();
if (mainMenu.equals("N"))
{
System.out.println("Thank you for banking with us!");
}
}
} while(mainMenu.equals("Y"));
}
}