desislava_topuzakova

10. Rage Expenses

May 21st, 2021
1,632
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.25 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class PrintAndSum_04 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int gamesLose = Integer.parseInt(scanner.nextLine());
  8.         double headsetPrice = Double.parseDouble(scanner.nextLine());
  9.         double mousePrice = Double.parseDouble(scanner.nextLine());
  10.         double keyboardPrice = Double.parseDouble(scanner.nextLine());
  11.         double displayPrice = Double.parseDouble(scanner.nextLine());
  12.  
  13.         int countHeadsets = gamesLose / 2;
  14.         int countMice = gamesLose / 3;
  15.         int countKeyboards = gamesLose / 6;
  16.         int countMonitors = gamesLose / 12;
  17.  
  18.         //разходи = (бр. слушалки * цена за 1 бр слушалки)
  19.         // + (бр. мишки * цена за 1 бр мишка)
  20.         // + (бр. клавиатури * цена за 1 бр клав)
  21.         // + (бр. монитори * цена за 1 бр монитор)
  22.         double expenses = (countHeadsets * headsetPrice)
  23.                 + (countMice * mousePrice)
  24.                 + (countKeyboards * keyboardPrice)
  25.                 + (countMonitors * displayPrice);
  26.  
  27.         System.out.printf("Rage expenses: %.2f lv.", expenses);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment