Advertisement
psi_mmobile

Untitled

Aug 27th, 2022
1,404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. public class MyClass {
  2.     public static void main(String args[]) {
  3.         java.util.Scanner scanner = new java.util.Scanner(System.in);
  4.         int lostGames = scanner.nextInt();
  5.         double headsetPrice = scanner.nextDouble();
  6.         double mousePrice = scanner.nextDouble();
  7.         double keyboardPrice = scanner.nextDouble();
  8.         double displayPrice = scanner.nextDouble();
  9.        
  10.         int kbSmashCount = 0;
  11.        
  12.         double damageCost = 0.0;
  13.        
  14.         for(int game = 1; game <= lostGames; game++) {
  15.             if(game % 2 == 0) {
  16.                 damageCost+=headsetPrice;
  17.             }
  18.             if (game % 3 == 0) {
  19.                 damageCost+=mousePrice;
  20.             }
  21.             if (game % 6 == 0) {
  22.                 kbSmashCount++;
  23.                 damageCost+=keyboardPrice;
  24.                 if (kbSmashCount % 2 == 0) {
  25.                     damageCost+=displayPrice;
  26.                 }
  27.             }
  28.         }
  29.         System.out.printf("Rage expenses: %.2f lv.", damageCost);
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement