Advertisement
veronikaaa86

01. Fruit Market

Nov 13th, 2021
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. package examPrep;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P01FruitMarket {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. double strawberryPrice = Double.parseDouble(scanner.nextLine());
  10. double bananasQuantity = Double.parseDouble(scanner.nextLine());
  11. double orangesQuantity = Double.parseDouble(scanner.nextLine());
  12. double raspberryQuantity = Double.parseDouble(scanner.nextLine());
  13. double strawberryQuantity = Double.parseDouble(scanner.nextLine());
  14.  
  15. double raspberryPrice = strawberryPrice / 2;
  16. double orangesPrice = raspberryPrice * 0.6;
  17. double bananasPrice = raspberryPrice * 0.20;
  18.  
  19. double allRaspberries = raspberryPrice * raspberryQuantity;
  20. double allStrawberries = strawberryPrice * strawberryQuantity;
  21. double allOranges = orangesPrice * orangesQuantity;
  22. double allBananas = bananasPrice * bananasQuantity;
  23.  
  24. double totalSum = allRaspberries + allStrawberries + allOranges + allBananas;
  25.  
  26. System.out.printf("%.2f", totalSum);
  27. }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement