Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- * Created by Ivan on 5/3/2017.
- */
- public class MartGame {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int enters = Integer.parseInt(scanner.nextLine());
- double zeroNine = 0;
- double tenNineteen = 0;
- double twentyTwentynine = 0;
- double thertyThertynine = 0;
- double fortyFifty = 0;
- double invalidNumber = 0;
- double totalPoint = 0;
- for (int i = 0; i < enters; i++) {
- double number = Integer.parseInt(scanner.nextLine());
- if (number >= 0 && number <=9){
- zeroNine ++;
- totalPoint += (0.2 * number);
- }
- if (number >= 10 && number <= 19){
- tenNineteen ++;
- totalPoint += (0.3 * number);
- }
- if (number >= 20 && number <= 29){
- twentyTwentynine++;
- totalPoint += (0.4 * number);
- }
- if (number >= 30 && number <=39){
- thertyThertynine ++;
- totalPoint += 50;
- }
- if (number >= 40 && number <= 50){
- fortyFifty ++;
- totalPoint += 100;
- }
- if (number < 0 || number > 50){
- invalidNumber ++;
- totalPoint = totalPoint / 2;
- }
- }
- System.out.printf("%.2f", totalPoint);
- System.out.println();
- System.out.printf("From 0 to 9: %.2f", (zeroNine * 100 / enters));
- System.out.print("%");
- System.out.println();
- System.out.printf("From 10 to 19: %.2f", (tenNineteen * 100 / enters));
- System.out.print("%");
- System.out.println();
- System.out.printf("From 20 to 29: %.2f", (twentyTwentynine * 100 / enters));
- System.out.print("%");
- System.out.println();
- System.out.printf("From 30 to 39: %.2f", (thertyThertynine * 100 / enters));
- System.out.print("%");
- System.out.println();
- System.out.printf("From 40 to 50: %.2f", (fortyFifty * 100 / enters));
- System.out.print("%");
- System.out.println();
- System.out.printf("Invalid numbers: %.2f", (invalidNumber * 100 / enters));
- System.out.print("%");
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement