Advertisement
kalin729

Fruit Market

Mar 7th, 2021
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main2 {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner s = new Scanner(System.in);
  9.  
  10.         double strawberryPrice = Double.parseDouble(s.nextLine());
  11.         double bananas = Double.parseDouble(s.nextLine());
  12.         double oranges = Double.parseDouble(s.nextLine());
  13.         double raspberries = Double.parseDouble(s.nextLine());
  14.         double strawberries = Double.parseDouble(s.nextLine());
  15.  
  16.         double raspberryPrice = strawberryPrice * 0.5;
  17.         double orangePrice = raspberryPrice * 0.6;
  18.         double bananaPrice = raspberryPrice * 0.2;
  19.  
  20.         double sum = (strawberries * strawberryPrice) + (raspberries * raspberryPrice) + (bananas * bananaPrice) + (oranges * orangePrice);
  21.         System.out.printf("%.2f", sum);
  22.  
  23.     }
  24.  
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement