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