Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class pcGameShopJuly2019 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int gameNumber = Integer.parseInt(scanner.next());//брой продадени игри
- int countHearthstone = 0;//брояч на различните видове игри
- int countFornite = 0;
- int countOverwatch = 0;
- int countOthers = 0;
- if (gameNumber > 0) {
- for (int i = 1; i <= gameNumber; i++) {
- String gameName = scanner.next();
- switch (gameName) {
- case "Hearthstone":
- countHearthstone++;
- break;
- case "Fornite":
- countFornite++;
- break;
- case "Overwatch":
- countOverwatch++;
- break;
- default:
- countOthers++;
- break;
- }
- }
- double hearthstonePercent = countHearthstone * 100.00 / gameNumber * 1.0;
- double fornitePercent = countFornite * 100*1.0 / gameNumber * 1.0;
- double overwatchPercent = countOverwatch *100*1.0/ gameNumber * 1.0;
- double othersPercent = countOthers *100*1.0 / gameNumber * 1.0;
- System.out.printf("Hearthstone - %.2f%%\n", hearthstonePercent);
- System.out.printf("Fornite - %.2f%%\n", fornitePercent);
- System.out.printf("Overwatch - %.2f%%\n", overwatchPercent);
- System.out.printf("Others - %.2f%%", othersPercent);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement