desislava_topuzakova

03. Painting Eggs

May 22nd, 2021
886
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.08 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class PrintAndSum_04 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         //печалба = цена за партида (броя и цвета) * бр. партиди
  7.         //крайна сума = печалба - разходи (35 % от печалбата)
  8.  
  9.         String sizeEggs = scanner.nextLine(); //"Large", "Medium" или "Small"
  10.         String colorEggs = scanner.nextLine(); //"Red", "Green" или "Yellow"
  11.         int count = Integer.parseInt(scanner.nextLine()); //брой партидите
  12.  
  13.         double price = 0; //цена на партидата
  14.  
  15.         switch (sizeEggs) {
  16.             case "Large":
  17.                 //проверка за цвета
  18.                 if (colorEggs.equals("Red")) {
  19.                     price = 16;
  20.                 } else if (colorEggs.equals("Green")) {
  21.                     price = 12;
  22.                 } else if (colorEggs.equals("Yellow")) {
  23.                     price = 9;
  24.                 }
  25.                 break;
  26.             case "Medium":
  27.                 //проверка за цвета
  28.                 if (colorEggs.equals("Red")) {
  29.                     price = 13;
  30.                 } else if (colorEggs.equals("Green")) {
  31.                     price = 9;
  32.                 } else if (colorEggs.equals("Yellow")) {
  33.                     price = 7;
  34.                 }
  35.                 break;
  36.             case "Small":
  37.                 //проверка за цвета
  38.                 if (colorEggs.equals("Red")) {
  39.                     price = 9;
  40.                 } else if (colorEggs.equals("Green")) {
  41.                     price = 8;
  42.                 } else if (colorEggs.equals("Yellow")) {
  43.                     price = 5;
  44.                 }
  45.                 break;
  46.         }
  47.  
  48.         double profit = count * price; //печалба
  49.         double expenses = 0.35 * profit; //разходи
  50.         double finalPrice = profit - expenses; //крайна цена
  51.  
  52.         System.out.printf("%.2f leva.", finalPrice);
  53.  
  54.     }
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment