Проблем със задача Small Shop от Programing Basics java
Здравейте, опитвам се да разбера къде греша?
Каквито и стойности да въведа получавам "0.0"
Пример:
beer
Sofia
6
0.0
Process finished with exit code 0
Ето го и кода ми
import java.util.Scanner; /** * Created by BinchoDinev on 2/24/2017. */ public class Shop { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String product = scanner.nextLine().toLowerCase(); String city = scanner.nextLine().toLowerCase(); double quantity = Double.parseDouble(scanner.nextLine()); double price = 0; if (city.equals("Sofia")) { if (product.equals("Coffee")) { price = 0.50; } else if (product.equals("water")) { price = 0.80; } else if (product.equals("beer")) { price = 1.20; } else if (product.equals("sweats")) { price = 1.45; } else if (product.equals("peanuts")) { price = 0.60; } } else if (city.equals("Plovdiv")) { if (product.equals("Coffee")) { price = 0.40; } else if (product.equals("water")) { price = 0.70; } else if (product.equals("beer")) { price = 1.15; } else if (product.equals("sweats")) { price = 1.30; } else if (product.equals("peanuts")) { price = 1.50; } } else if (city.equals("Varna")) { if (product.equals("Coffee")) { price = 0.45; } else if (product.equals("water")) { price = 0.70; } else if (product.equals("beer")) { price =1.10; } else if (product.equals("sweats")) { price = 1.35; } else if (product.equals("peanuts")) { price = 1.55; } } double total = price * quantity; System.out.println(total); } }
Разбрах!
Благодаря и на двама ви!