-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhome.java
More file actions
122 lines (111 loc) · 3.57 KB
/
home.java
File metadata and controls
122 lines (111 loc) · 3.57 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import java.util.*;
import java.time.*;
import java.time.format.*;
import java.io.*;
public class home
{
static Scanner sc = new Scanner(System.in);
boolean run = true;
static String Username = null;
home()
{}
public void homescreen() throws Exception
{
System.out.println("What you would like to do?");
System.out.println("\u001b[31m1. Enter new expenses\n2. Edit previous expenses\n3. Total this month's expenses\n4. Add Payment Source \nEnter -1 to exit");
System.out.print("\u001b[32mINPUT-> ");
int input = sc.nextInt();
System.out.print("\u001b[0m");
switch(input)
{
case 1:
expense();
break;
case 2:
editEntry editEntry = new editEntry(Username);
editEntry.main();
break;
case 3:
/* Monthly sum */
System.out.println("Choose the Month");
break;
case 4:
/* add credit card/debit card/others */
break;
case -1: /*USING -1 AS AN EXIT COMMAND MAY BE CHANGED LATER*/
System.out.println("Thank you for using this app. The app will quit now.");
run = false;
break;
default:
System.out.println("Can't get it pls try again."); }
}
public void main() throws Exception
{
try
{
System.out.println("\u001b[36mWelcome to My Expenses app.\u001b[0m");
Thread.sleep(1000);
DateTimeFormatter dt = DateTimeFormatter.ofPattern("E, dd-MM-yyyy HH:mm:ss");
LocalDateTime date = LocalDateTime.now();
System.out.println("Current date/time: \u001b[36m" + date.format(dt) + "\u001b[0m");
Thread.sleep(1000);
System.out.println("Enter Your username");
Username = sc.nextLine();
System.out.println("Welcome " + Username);
while(run)
{
Thread.sleep(2000);
homescreen();
}
}
catch (Exception E)
{
//E.printStackTrace();
System.out.println("OOPSS! Seems like something went wrong. Please Restart the program.");
}
}
public static void expense() throws Exception
{
System.out.println("Categories are as follows");
System.out.println("1. Transportation \n2. Food \n3. Household \n4. Apparel \n5. Dairy");
System.out.println("Enter a category");
int cat = sc.nextInt();
switch (cat)
{
case 1:
System.out.println("You've Chosen Transportation \nSo How much did you spend");
int trns = sc.nextInt();
newEntry n1 = new newEntry(Username, 1 , trns );
break;
case 2:
System.out.println("You've Chosen Food \nSo How much did you spend");
int fo = sc.nextInt();
newEntry n2 = new newEntry(Username, 2 , fo );
break;
case 3:
System.out.println("You've Chosen Household \nSo How much did you spend");
int ho = sc.nextInt();
newEntry n3 = new newEntry(Username,3 , ho );
break;
case 4:
System.out.println("You've Chosen Apparel \nSo How much did you spend");
int ap = sc.nextInt();
newEntry n4 = new newEntry(Username, 4 , ap );
break;
case 5:
System.out.println("You've Chosen Dairy \nSo How much did you spend");
int dar = sc.nextInt();
newEntry n5 = new newEntry(Username ,5 , dar );
break;
default:
expense();
}
}
}
/*
* Home - First homescreen page
* Enter Expenses - to enter new expense
* Edit Entry - Edit previuos entries (Scope - 10 Days)
*
**/
// Transportation, Food, Household, Apparel, Dairy