Advertisement
desislava_topuzakova

11. Rage Expenses

May 21st, 2022
941
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.48 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class RageExpenses_11 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         //headset, mouse, keyboard, and display
  7.         int gamesLost = 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 headsetCount = gamesLost / 2;
  14.         int mouseCount = gamesLost / 3;
  15.         int keyboardCount = gamesLost / 6;
  16.         int displayCount = gamesLost / 12;
  17.  
  18.         //сума за слушалки = бр. слушалки * headsetPrice
  19.         //сума за мишки = бр. мишки * mousePrice
  20.         //сума за клавиатури = бр. клавиатури * keyboardPrice
  21.         //сума за монитори = бр. монитори * displayPrice
  22.         //обща сума = сума за слушалки + сума за мишки + сума за клавиатура + сума за монитори
  23.         double totalSum = (headsetCount * headsetPrice)
  24.                          + (mouseCount * mousePrice)
  25.                          + (keyboardCount * keyboardPrice)
  26.                          + (displayCount * displayPrice);
  27.         System.out.printf("Rage expenses: %.2f lv.", totalSum);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement