Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.util.ArrayList;
- import java.util.Scanner;
- import static java.lang.Math.ceil;
- public class Main {
- public static void main(String[] args)
- throws Exception
- {
- File text = new File("/Users/vraj8725/IdeaProjects/ECOO Practise/src/DATA11.txt");
- Scanner s = new Scanner(text);
- ArrayList<String> ll = new ArrayList<>();
- while(s.hasNextLine()) {
- ll.add(s.nextLine());
- }
- int c = 0;
- int o = 0;
- int b =0;
- int g=0;
- int y=0;
- int p=0;
- int v=0;
- int br=0;
- int r=0;
- for (int i = 0; i < ll.size(); i++) {
- if(ll.get(i).equals("red")) {r++;}
- else if(ll.get(i).equals("orange")) {o++;}
- else if(ll.get(i).equals("blue")) {b++;}
- else if(ll.get(i).equals("green")){g++;}
- else if(ll.get(i).equals("yellow")){y++;}
- else if(ll.get(i).equals("pink")){p++;}
- else if(ll.get(i).equals("violet")){v++;}
- else if(ll.get(i).equals("brown")){br++;}
- else if(ll.get(i).equals("end of box")){
- c += Math.ceil(o/7f) * 13;
- c += Math.ceil(b/7f) * 13;
- c += ((ceil(g/7f)) * 13);
- c += ((ceil(y/7f)) * 13);
- c += ((ceil(p/7f))* 13);
- c += ((ceil(v/7f)) * 13);
- c += ((ceil(br/7f)) * 13);
- c+= r*16;
- System.out.print(c +"\n");
- c = o = b = g = y= p = v = br= r = 0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement