Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class RageExpenses {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int lostGameCnt = Integer.parseInt(scan.nextLine());
- double headsetPrice = Double.parseDouble(scan.nextLine());
- double mousePrice = Double.parseDouble(scan.nextLine());
- double keyboardPrice = Double.parseDouble(scan.nextLine());
- double displayPrice = Double.parseDouble(scan.nextLine());
- int headsetCrashCnt = 0;
- int mouseCrashCnt = 0;
- int keyboardCrashCnt = 0;
- int displayCrashCnt = 0;
- double expenses = 0;
- for (int i = 1; i <= lostGameCnt; i++) {
- if (i % 2 == 0) {
- headsetCrashCnt++;
- }
- if (i % 3 == 0) {
- mouseCrashCnt++;
- }
- if (i % 2 == 0 && i % 3 == 0) {
- keyboardCrashCnt++;
- }
- }
- displayCrashCnt = keyboardCrashCnt / 2;
- expenses = (headsetCrashCnt * headsetPrice)
- + (mouseCrashCnt * mousePrice) +
- (keyboardCrashCnt * keyboardPrice) + (displayCrashCnt * displayPrice);
- System.out.printf("Rage expenses: %.2f lv.",expenses);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement