Removing files from data analysis directory
[ou-summer-of-code-2017.git] / 00-holiday-specs / Day0.java
1 import java.util.Scanner;
2 import java.util.Scanner.*;
3 import java.io.FileReader;
4 import java.io.FileReader.*;
5
6 public class Day0
7 {
8 public static void main(String[] args) throws Exception
9 {
10 FileReader f = new FileReader("00-prices.txt");
11 Scanner sc = new Scanner(f);
12
13 String id, bestId = "";
14 int nullarbor = 0;
15 int price, extras, nextCost;
16 int bestCost = Integer.MAX_VALUE;
17
18 while(sc.hasNext())
19 {
20 id = sc.next();
21
22 price = sc.nextInt();
23
24 String lo = sc.next();
25
26 if(lo.contains("Nullarbor"))
27 nullarbor++;
28
29 extras = sc.nextInt();
30
31 nextCost = price + extras;
32
33 int savings = Math.min(extras, 500);
34
35 nextCost -= savings;
36
37 if(nextCost < bestCost)
38 {
39 bestCost = nextCost;
40 bestId = id;
41 }
42 }
43
44 System.out.println("Nullarbor holidays " + nullarbor);
45 System.out.println("Best price holiday " + bestCost + " id " + bestId );
46 }
47 }