This repository was archived by the owner on Oct 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInsurance.java
More file actions
40 lines (34 loc) · 1.36 KB
/
Insurance.java
File metadata and controls
40 lines (34 loc) · 1.36 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
import java.lang.*;
import java.io.*;
public class Insurance {
public static void main(String args[]) {
try {
BufferedReader br = new BufferedReader(new FileReader("data.txt"));
String line = null;
while ((line = br.readLine()) != null) {
String[] split = line.split("\\s+");
// for(int i = 0; i < split.length; i++)
// System.out.println(split[i]);
String fn = split[0];
String ln = split[1];
int age = Integer.parseInt(split[2]);
double yearlyRate;
if(age > 16 && age < 19)
yearlyRate = (1000 * .15) + 1000;
else if(age > 20 && age < 25)
yearlyRate = (1000 * .05) + 1000;
else if(age > 25)
yearlyRate = 1000 - (1000 * .1);
else {
yearlyRate = 0;
System.out.println("This person isnt eligible for insurance");
}
System.out.println("Name: " + fn + " " + ln + ", Age: " + age + "\n" + "Yearly Rate: " + Double.toString(yearlyRate) + "\n");
}
br.close();
}
catch(Exception e){
System.out.println("An unknown error occurred, please try again");
}
}
}