Advertisement
psi_mmobile

Untitled

Aug 27th, 2022
1,346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. public class MyClass {
  2.     public static void main(String args[]) {
  3.         java.util.Scanner scanner = new java.util.Scanner(System.in);
  4.         int orders = scanner.nextInt();
  5.         double pricePerCapsule = 0.0;
  6.         int days = 0;
  7.         int capsules = 0;
  8.        
  9.         double calculatedStep = 0.0;
  10.         double totalPriceOfCoffee = 0.0;
  11.        
  12.         for (int orderNum = 1; orderNum <= orders; orderNum++) {
  13.             pricePerCapsule = scanner.nextDouble();
  14.             days = scanner.nextInt();
  15.             capsules = scanner.nextInt();
  16.             calculatedStep = pricePerCapsule * days * capsules;
  17.             totalPriceOfCoffee += calculatedStep;
  18.             System.out.printf("The price for the coffee is: $%.2f\n",calculatedStep);
  19.         }
  20.         System.out.printf("Total: $%.2f",totalPriceOfCoffee);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement