-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathURI_1094.java
More file actions
50 lines (38 loc) · 1.24 KB
/
URI_1094.java
File metadata and controls
50 lines (38 loc) · 1.24 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
import java.io.IOException;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
int total=0,total_C=0,total_R=0,total_S=0 ;
double percent_C=0,percent_R=0,percent_S=0;
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
String name ;
for (int i = 0; i < N; i++) {
total = scanner.nextInt();
name = scanner.next();
if (name.equals("C")) {
total_C = total_C + total;
}
else if (name.equals("R")) {
total_R += total;
}
else {
total_S += total;
}
total=total_C+total_R+total_S;
}
System.out.println("Total: "+total+" cobaias");
System.out.println("Total de coelhos: "+total_C);
System.out.println("Total de ratos: "+total_R);
System.out.println("Total de sapos: "+total_S);
percent_C = (double)((total_C*100.00)/total);
percent_R = (double)((total_R*100.00)/total);
percent_S = (double)((total_S*100.00)/total);
System.out.printf("Percentual de coelhos: %.2f",percent_C);
System.out.println(" %");
System.out.printf("Percentual de ratos: %.2f",percent_R);
System.out.println(" %");
System.out.printf("Percentual de sapos: %.2f",percent_S);
System.out.println(" %");
}
}