Guest User

Untitled

a guest
Sep 30th, 2018
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.79 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String fruit = scanner.nextLine() ;
  7.         String day = scanner.nextLine() ;
  8.         double quantity = Double.parseDouble(scanner.nextLine()) ;
  9.  
  10.         double price = 0 ;
  11.  
  12.         if("Monday".equals(day) ||
  13.                 "Tuesday".equals(day)||
  14.                 "Wednesday".equals(day)||
  15.                 "Thursday".equals(day)||
  16.                 "Friday".equals(day)) {
  17.         if ("banana".equals(fruit)) {
  18.             price = 2.50 ;
  19.         }else if ("apple".equals(fruit)){
  20.             price = 1.20 ;
  21.  
  22.         }else if ("orange".equals(fruit)){
  23.             price = 0.85 ;
  24.  
  25.         }else if ("grapefruit".equals(fruit)){
  26.             price = 1.45 ;
  27.         }else if ("kiwi".equals(fruit)){
  28.             price = 2.70 ;
  29.  
  30.         }else if ("pineapple".equals(fruit)) {
  31.             price = 5.50 ;
  32.  
  33.         }else if ("grapes".equals(fruit)){
  34.             price = 3.85 ;
  35.         }
  36.         }
  37.        
  38.         else if ("Saturday".equals(day) || "Sunday".equals(day)){
  39.         if ("banana".equals(fruit)) {
  40.             price = 2.70;
  41.         }else if ("apple".equals(fruit)){
  42.             price = 1.25 ;
  43.         }else if ("orange".equals(fruit)){
  44.             price = 0.90 ;
  45.         }else if ("grapefruit".equals(fruit)){
  46.             price = 1.60 ;
  47.         }else if ("kiwi".equals(fruit)){
  48.             price = 3.00 ;
  49.         }else if ("pineapple".equals(fruit)) {
  50.             price = 5.60 ;
  51.         }else if ("grapes".equals(fruit)){
  52.             price = 4.20 ;
  53.         }
  54.         }
  55.         if (price > 0){
  56.             System.out.printf("%.2f", price * quantity);
  57.         }else {
  58.             System.out.println("error");
  59.         }
  60.     }
  61. }
Add Comment
Please, Sign In to add comment