Advertisement
desislava_topuzakova

09. Orders

May 21st, 2022
990
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E09Orders {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int countOfOrders = Integer.parseInt(scanner.nextLine());
  10.         double coffeePrice = 0;
  11.         double totalPrice = 0;
  12.  
  13.         for (int i = 0; i < countOfOrders; i++) {
  14.             double pricePerCapsule = Double.parseDouble(scanner.nextLine());
  15.             int daysInMonth = Integer.parseInt(scanner.nextLine());
  16.             int capsulesCount = Integer.parseInt(scanner.nextLine());
  17.  
  18.             coffeePrice = ((daysInMonth * capsulesCount) * pricePerCapsule);
  19.             totalPrice += coffeePrice;
  20.  
  21.             System.out.printf("The price for the coffee is: $%.2f%n", coffeePrice);
  22.         }
  23.         System.out.printf("Total: $%.2f%n", totalPrice);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement