Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner Scanner = new Scanner(System.in);
- String product = Scanner.nextLine();
- String dayOfWeek = Scanner.nextLine();
- double quantity = Double.parseDouble(Scanner.nextLine());
- double price = 0;
- if(dayOfWeek.equalsIgnoreCase("Monday") || (dayOfWeek.equalsIgnoreCase("Tuesday")) ||
- (dayOfWeek.equalsIgnoreCase("Wednesday")) || (dayOfWeek.equalsIgnoreCase("Thursday"))
- || (dayOfWeek.equalsIgnoreCase("Friday"))){
- if(product.equalsIgnoreCase("banana")){
- price = quantity * 2.5;
- }else if (product.equalsIgnoreCase("apple")){
- price = quantity * 1.2;
- }else if(product.equalsIgnoreCase("orange")){
- price = quantity * 0.85;
- }else if (product.equalsIgnoreCase("grapefruit")){
- price = quantity * 1.45;
- }else if(product.equalsIgnoreCase("kiwi")){
- price = quantity * 2.7;
- }else if(product.equalsIgnoreCase("pineapple")){
- price = quantity * 5.5;
- }else if(product.equalsIgnoreCase("grapes")){
- price = quantity * 3.85;
- }else{
- System.out.println("error");
- }
- }else if(dayOfWeek.equalsIgnoreCase("Saturday") || (dayOfWeek.equalsIgnoreCase("Sunday"))){
- if(product.equalsIgnoreCase("banana")){
- price = quantity * 2.7;
- }else if (product.equalsIgnoreCase("apple")){
- price = quantity * 1.25;
- }else if(product.equalsIgnoreCase("orange")){
- price = quantity * 0.9;
- }else if (product.equalsIgnoreCase("grapefruit")){
- price = quantity * 1.60;
- }else if(product.equalsIgnoreCase("kiwi")){
- price = quantity * 3;
- }else if(product.equalsIgnoreCase("pineapple")){
- price = quantity * 5.6;
- }else if(product.equalsIgnoreCase("grapes")){
- price = quantity * 4.2;
- }else{
- System.out.println("error");
- }
- }else{
- System.out.println("error");
- }
- System.out.println(price);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment