Advertisement
grach

Rage expenses

May 26th, 2020
838
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.06 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.  
  7.         int lostGame = Integer.parseInt(scan.nextLine());
  8.  
  9.         double headsetPrice = Double.parseDouble(scan.nextLine());
  10.         double mousePrice = Double.parseDouble(scan.nextLine());
  11.         double keyboardPrice = Double.parseDouble(scan.nextLine());
  12.         double displayPrice = Double.parseDouble(scan.nextLine());
  13.  
  14.         int displayCount = 0;
  15.         double sum = 0;
  16.  
  17.         for (int i = 1; i <= lostGame; i++) {
  18.             if (i % 2 == 0) {
  19.                 sum += headsetPrice;
  20.             }
  21.             if (i % 3 == 0) {
  22.                 sum += mousePrice;
  23.             }
  24.             if ((i % 2 == 0) && (i % 3 == 0)) {
  25.                 sum += keyboardPrice;
  26.                 displayCount++;
  27.  
  28.                 if (displayCount % 2 == 0) {
  29.                     sum += displayPrice;
  30.                 }
  31.             }
  32.         }
  33.         System.out.printf("Rage expenses: %.2f lv.", sum);
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement