Advertisement
Guest User

Smarties (ECOO #1 2015)

a guest
Mar 21st, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.63 KB | None | 0 0
  1. import java.io.File;
  2. import java.util.ArrayList;
  3. import java.util.Scanner;
  4.  
  5. import static java.lang.Math.ceil;
  6.  
  7. public class Main {
  8.  
  9.     public static void main(String[] args)
  10.         throws Exception
  11.     {
  12.  
  13.  
  14.         File text = new File("/Users/vraj8725/IdeaProjects/ECOO Practise/src/DATA11.txt");
  15.         Scanner s = new Scanner(text);
  16.         ArrayList<String> ll = new ArrayList<>();
  17.         while(s.hasNextLine()) {
  18.             ll.add(s.nextLine());
  19.         }
  20.         int c = 0;
  21.         int o = 0;
  22.         int b =0;
  23.         int g=0;
  24.         int y=0;
  25.         int p=0;
  26.         int v=0;
  27.         int br=0;
  28.         int r=0;
  29.         for (int i = 0; i < ll.size(); i++) {
  30.             if(ll.get(i).equals("red")) {r++;}
  31.             else if(ll.get(i).equals("orange")) {o++;}
  32.             else if(ll.get(i).equals("blue")) {b++;}
  33.             else if(ll.get(i).equals("green")){g++;}
  34.             else if(ll.get(i).equals("yellow")){y++;}
  35.             else if(ll.get(i).equals("pink")){p++;}
  36.             else if(ll.get(i).equals("violet")){v++;}
  37.             else if(ll.get(i).equals("brown")){br++;}
  38.             else if(ll.get(i).equals("end of box")){
  39.                 c += Math.ceil(o/7f) * 13;
  40.                 c += Math.ceil(b/7f) * 13;
  41.                 c += ((ceil(g/7f)) * 13);
  42.                 c += ((ceil(y/7f)) * 13);
  43.                 c += ((ceil(p/7f))* 13);
  44.                 c += ((ceil(v/7f)) * 13);
  45.                 c += ((ceil(br/7f)) * 13);
  46.                 c+= r*16;
  47.                 System.out.print(c +"\n");
  48.                 c = o = b = g = y= p = v = br= r = 0;
  49.             }
  50.  
  51.         }
  52.  
  53.  
  54.  
  55.        
  56.  
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement