Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class EnergyBooster{
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- // Плод - текст с възможности: "Watermelon", "Mango", "Pineapple" или "Raspberry"
- String fruit = scanner.nextLine();
- //2. Размерът на сета - текст с възможности: "small" или "big"
- String packageSize = scanner.nextLine();
- //3. Брой на поръчаните сетове - цяло число в интервала [1 … 10000]
- int numberOfPackages = Integer.parseInt(scanner.nextLine());
- // Диня Манго Ананас Малина "Watermelon", "Mango", "Pineapple" или "Raspberry"
- // 2 броя (small) 56 лв./бр. 36.66 лв./бр. 42.10 лв./бр. 20 лв./бр.
- // 5 броя (big) 28.70 лв./бр. 19.60 лв./бр. 24.80 лв./бр. 15.20 лв./бр.
- double PriceWithoutDiscount = 0;
- switch (fruit) {
- case "Watermelon":
- switch (packageSize) {
- case "small":
- PriceWithoutDiscount = 56 * 2;
- break;
- case "big":
- PriceWithoutDiscount = 28.70 * 5;
- break;
- }
- break;
- case "Mango":
- switch (packageSize) {
- case "small":
- PriceWithoutDiscount = 36.66 * 2;
- break;
- case "big":
- PriceWithoutDiscount = 19.60 * 5;
- break;
- }
- break;
- case "Pineapple":
- switch (packageSize) {
- case "small":
- PriceWithoutDiscount = 42.10 * 2;
- break;
- case "big":
- PriceWithoutDiscount = 24.80 * 5;
- break;
- }
- break;
- case "Raspberry":
- switch (packageSize) {
- case "small":
- PriceWithoutDiscount = 20 * 2;
- break;
- case "big":
- PriceWithoutDiscount = 15.20 * 5;
- }
- }
- double TotalPriceWithoutDiscount = PriceWithoutDiscount * numberOfPackages;
- if ( 400 <= TotalPriceWithoutDiscount && TotalPriceWithoutDiscount <= 1000) {
- double Discount = 0.15 * TotalPriceWithoutDiscount;
- double EndPrice = TotalPriceWithoutDiscount - Discount;
- System.out.printf("%.2f lv.", EndPrice);
- }
- else if (TotalPriceWithoutDiscount > 1000) {
- double Discount = 0.5 * TotalPriceWithoutDiscount;
- double EndPrice = TotalPriceWithoutDiscount - Discount;
- System.out.printf("%.2f lv.", EndPrice);
- }
- else{
- System.out.printf("%.2f lv.",TotalPriceWithoutDiscount);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement