stoyanoff

FruitShop

Jun 11th, 2020
1,016
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.60 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FruitMarket_07 {
  4.     public static void main(String[] args) {
  5.         Scanner myScan = new Scanner(System.in);
  6.  
  7.  
  8.         double strawberryPrice = Double.parseDouble(myScan.nextLine());
  9.         double bananasAmount =  Double.parseDouble(myScan.nextLine());
  10.         double orangesAmount =  Double.parseDouble(myScan.nextLine());
  11.         double raspberryAmount =  Double.parseDouble(myScan.nextLine());
  12.         double strawberryAmount =  Double.parseDouble(myScan.nextLine());
  13.  
  14.         // цената на малините е с 50% по-ниска от тази на ягодите;
  15.         double raspberryPrice = strawberryPrice / 2.0;
  16.         //•   цената на портокалите е с 40% по-ниска от цената на малините;
  17.         double orangesPrice = raspberryPrice - (raspberryPrice * 40/100);
  18.         // •  цената на бананите е с 80% по-ниска от цената на малините.
  19.         double bananasPrice = raspberryPrice - (raspberryPrice * 80/100);
  20.  
  21.         // Cost for strawberries
  22.         double strawberryCost = strawberryAmount * strawberryPrice;
  23.         // Cost for bananas
  24.         double bananasCost = bananasAmount * bananasPrice;
  25.         // Cost for Oranges
  26.         double orangesCost = orangesAmount * orangesPrice;
  27.         // Cost for Raspberry
  28.         double raspberryCost = raspberryAmount * raspberryPrice;
  29.  
  30.         // Total cost
  31.  
  32.         double totalCost = strawberryCost + raspberryCost + bananasCost + orangesCost;
  33.  
  34.         System.out.printf("%.2f", totalCost);
  35.  
  36.  
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment