-
Notifications
You must be signed in to change notification settings - Fork 2
/
Payment.java
124 lines (119 loc) · 3.97 KB
/
Payment.java
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
123
124
package billing;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class Payment extends Thread
{
private String payment_mode;
public void verify_user()
{
System.out.println("Verification of account.....");
System.out.println("Please wait for a while....");
System.out.println();
try
{
Thread.sleep(3000);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
System.out.println();
System.out.println("----------------------Verified----------------------");
}
public void display_payment_details() {
System.out.println("Processing Payment details....");
System.out.println("Please wait...");
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("Payment Successful!!!");
File myFile = new File("total_income.txt");
double tot = 0;
try {
Scanner sc = new Scanner(myFile);
if (sc.hasNextLine()) {
String temp = sc.nextLine();
tot = Double.parseDouble(temp);
}
} catch (FileNotFoundException e) {
System.out.println("Err.....cannot find records!!!");
System.out.println("Please try again after some time!");
}
File cart = new File("current_user.txt");
double total_price;
double cart_total = 0;
try {
Scanner sc = new Scanner(cart);
String temp;
if (sc.hasNextLine()) {
temp = sc.nextLine();
}
int f = 1;
while (sc.hasNext()) {
temp = sc.next();
if (f % 5 == 0) {
total_price = Double.parseDouble(temp);
cart_total += total_price;
}
f++;
}
tot += cart_total;
FileWriter fout = new FileWriter("total_income.txt");
temp = String.valueOf(tot);
fout.write(temp);
fout.close();
System.out.println("You made payment through " + payment_mode);
int rand = (int) (Math.random() * (double) 1000000);
System.out.println("Your payment id generated is " + rand);
System.out.println();
System.out.println("A code has been sent to your registered mobile number");
System.out.println("Kindly make sure that it matches with the generated id");
System.out.println("In case of mismatch kindly contact Support at - 8787878787");
System.out.println();
new feedbackGUI();
} catch (IOException e)
{
System.out.println("Err.....cannot find records!!!");
System.out.println("Please try again after some time!");
}
}
public void get_payment_mode()
{
System.out.println("Enter your desired mode of payment");
System.out.println("1. Debit Card");
System.out.println("2. Credit Card");
System.out.println("3. UPI");
System.out.println("4. PAYTM");
char ch;
Scanner sc = new Scanner(System.in);
ch = sc.next().charAt(0);
//system(clear);
if(ch=='1')
{
payment_mode = "Debit Card";
}
else if(ch=='2')
{
payment_mode = "Credit Card";
}
else if(ch=='3')
{
payment_mode = "UPI";
}
else if(ch=='4')
{
payment_mode = "PAYTM";
}
else
{
System.out.println("Err....Invalid Input");
System.out.println("Choose again");
get_payment_mode();
}
}
}