Advertisement
Ivelin_Arsov

RageExpenses

May 22nd, 2020
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class RageExpenses {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         int lostGameCnt = Integer.parseInt(scan.nextLine());
  7.         double headsetPrice = Double.parseDouble(scan.nextLine());
  8.         double mousePrice = Double.parseDouble(scan.nextLine());
  9.         double keyboardPrice = Double.parseDouble(scan.nextLine());
  10.         double displayPrice = Double.parseDouble(scan.nextLine());
  11.  
  12.         int headsetCrashCnt = 0;
  13.         int mouseCrashCnt = 0;
  14.         int keyboardCrashCnt = 0;
  15.         int displayCrashCnt = 0;
  16.         double expenses = 0;
  17.  
  18.         for (int i = 1; i <= lostGameCnt; i++) {
  19.             if (i % 2 == 0) {
  20.                 headsetCrashCnt++;
  21.             }
  22.             if (i % 3 == 0) {
  23.                 mouseCrashCnt++;
  24.             }
  25.             if (i % 2 == 0 && i % 3 == 0) {
  26.                 keyboardCrashCnt++;
  27.             }
  28.         }
  29.         displayCrashCnt = keyboardCrashCnt / 2;
  30.         expenses = (headsetCrashCnt * headsetPrice)
  31.                 + (mouseCrashCnt * mousePrice) +
  32.                 (keyboardCrashCnt * keyboardPrice) + (displayCrashCnt * displayPrice);
  33.         System.out.printf("Rage expenses: %.2f lv.",expenses);
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement