Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Scholarship {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String product = scanner.nextLine().toLowerCase();
- String day = scanner.nextLine().toLowerCase();
- double quantity = Double.parseDouble(scanner.nextLine());
- double price = 0;
- boolean Weekdays = day.equals("monday") || day.equals("tuesday") || day.equals("wednesday") || day.equals("thursday") || day.equals("friday");
- boolean Weekend = day.equals("saturday") || day.equals("sunday");
- if (product.equals("banana")) {
- if (Weekdays) {
- price = 2.50;
- } else if (Weekend) {
- price = 2.70;
- }
- } else if (product.equals("apple")) {
- if (Weekdays) {
- price = 1.20;
- } else if (Weekend) {
- price = 2.25;
- }
- } else if (product.equals("orange")) {
- if (Weekdays) {
- price = 0.85;
- } else if (Weekend) {
- price = 0.90;
- }
- } else if (product.equals("grapefruit")) {
- if (Weekdays) {
- price = 1.45;
- } else if (Weekend) {
- price = 2.60;
- }
- } else if (product.equals("kiwi")) {
- if (Weekdays) {
- price = 2.70;
- } else if (Weekend) {
- price = 3.00;
- }
- } else if (product.equals("pineapple")) {
- if (Weekdays) {
- price = 5.50;
- } else if (Weekend) {
- price = 5.60;
- }
- } else if (product.equals("grapes")) {
- if (Weekdays) {
- price = 3.85;
- } else if (Weekend) {
- price = 4.20;
- }
- double result = price * quantity;
- System.out.println(result);
- } else {
- System.out.println("error");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement