-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParanoia.java
More file actions
55 lines (53 loc) · 2.07 KB
/
Paranoia.java
File metadata and controls
55 lines (53 loc) · 2.07 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
/*ByteCorp is a famous technological company in Byteania.
The CEO of ByteCorp doesn't trust anyone and thinks that his accountant managed to move huge amounts of money to a competitor company, MegaCorp.
He hires a computer crime investigator, and asks him to find inconsistencies in the money transfers.
Here is a sample transaction log of the company:
Feb SLR 4 M
Feb ENT 800 K
Mar SLR 4000 K
Mar ENT 800 K
Apr SLR 4010 K
Apr ENT 810 K
There are four columns:
1. Month of the transaction
2. Reason of the expense (SLR for "salary", ENT for "entertainment", OTR for "other")
3. Amount
4. M, K, or B (M for million, K for thousands, B for billion)
In the example above, April expenses show an inconsistency and should be reported.
As the computer investigator, write a program, which reads the transaction logs, detects inconsistent expenses and prints the exact month containing the "unusual" activities.
*/
import java.util.*;
public class Paranoia{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter the number records");
int rec = in.nextInt();
in.nextLine();
String month[] = new String[rec];
String reason[] = new String[rec];
String amt[] = new String[rec];
System.out.println("Enter the Records!");
for (int i=0;i<rec ;i++ ) {
String str = in.nextLine();
String strsplit[] = str.split(" ");
month[i] = strsplit[0];
reason[i] = strsplit[1];
amt[i] = strsplit[2];
}
int flag=0;
System.out.println("********** ByteCorp **********");
for (int i=0;i<rec;) {
if (amt[i++].equals("4000") && amt[i++].equals("800") && amt[i++].equals("1190")) {}
else{
if (reason[i-1].equals("SLR")) {
System.out.println("Unusual Activities with Salary in the month of "+month[i-1]);
}else if (reason[i-1].equals("ENR")) {
System.out.println("Unusual Activities with Entertainment Expenses in the month of "+month[i-1]);
}
else{
System.out.println("Unusual Activities Detected with Other Expenses in the month of "+month[i-1]);
}
}
}
}
}