Advertisement
desislava_topuzakova

11. Rage Expenses

Sep 17th, 2022
1,019
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.32 KB | None | 0 0
  1. package basicSyntax.exercise;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class RageExpenses_11 {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         //1. входни данни
  9.         int lostGames = Integer.parseInt(scanner.nextLine());
  10.         double headsetPrice = Double.parseDouble(scanner.nextLine());
  11.         double mousePrice = Double.parseDouble(scanner.nextLine());
  12.         double keyboardPrice = Double.parseDouble(scanner.nextLine());
  13.         double displayPrice = Double.parseDouble(scanner.nextLine());
  14.  
  15.         //2. крайна сума =
  16.         // (countHeadset * headsetPrice)
  17.         // + (countMouse * mousePrice)
  18.         // + (countKeyboard * keyboardPrice)
  19.         // + (countDisplay * displayPrice)
  20.  
  21.         int countHeadset = lostGames / 2; //бр. слушалки
  22.         int countMouse = lostGames / 3; //бр. мишка
  23.         int countKeyboard = lostGames / 6; //бр. клавиатурите
  24.         int countDisplay = lostGames / 12; //бр. монитори
  25.  
  26.         double finalSum = (countHeadset * headsetPrice)
  27.                 + (countMouse * mousePrice)
  28.                 + (countKeyboard * keyboardPrice)
  29.                 + (countDisplay * displayPrice);
  30.  
  31.         System.out.printf("Rage expenses: %.2f lv.", finalSum);
  32.  
  33.  
  34.     }
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement