Advertisement
desislava_topuzakova

09. Orders

Sep 17th, 2022
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. package BasicSyntaxExercise;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Orders {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. int orders = Integer.parseInt(scanner.nextLine());
  10. double price = 0;
  11. int days = 0;
  12. int capsulesCount = 0;
  13. double sum = 0;
  14. double currentPrice = 0;
  15.  
  16. for (int i = 1; i <=orders ; i++) {
  17. price = Double.parseDouble(scanner.nextLine());
  18. days = Integer.parseInt(scanner.nextLine());
  19. capsulesCount = Integer.parseInt(scanner.nextLine());
  20. currentPrice = (days * capsulesCount) * price;
  21. System.out.printf("The price for the coffee is: $%.2f%n", currentPrice);
  22. sum = sum + currentPrice;
  23.  
  24. }
  25. System.out.printf("Total: $%.2f", sum);
  26.  
  27.  
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement