Advertisement
desislava_topuzakova

06. Charity Campaign

Oct 5th, 2020
735
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.91 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class CharityCampaign_06 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         //1. сума на сладкар за 1 ден = сума за торти + сума за гофрети + сума за палачинки - ок
  8.             //сума за торти = бр.торти * цена за торта (45лв) - ok
  9.             //сума за гофрети = бр.гофрети * цена за гофрета (5.80) - ok
  10.             //сума за палачинки = бр. палачинки * цена за палачинка(3.20) - ok
  11.         //2. сума за всички сладкари за 1 ден = бр. сладкари * сума на сладкар за 1 ден
  12.         //3. общо за всички дни = сума за всички сладкари за 1 ден * бр. дни
  13.         //4. разходи = 1 / 8 от общо за всички дни
  14.         //5. крайна сума = общо за всички дни - разходи
  15.  
  16.         int countDays = Integer.parseInt(scanner.nextLine());
  17.         int countBakers = Integer.parseInt(scanner.nextLine());
  18.         int countCakes = Integer.parseInt(scanner.nextLine());
  19.         int countWaffles = Integer.parseInt(scanner.nextLine());
  20.         int countPancakes = Integer.parseInt(scanner.nextLine());
  21.  
  22.         double priceCakes = countCakes * 45;
  23.         double priceWaffles = countWaffles * 5.80;
  24.         double pricePancakes = countPancakes * 3.20;
  25.  
  26.         double sumPerBakerForDay = priceCakes + priceWaffles + pricePancakes; //1 сладкар за 1 ден
  27.         double sumAllBakersForDay  = sumPerBakerForDay * countBakers;
  28.         double sumAllDays = sumAllBakersForDay * countDays;
  29.         double expenses = sumAllDays / 8;
  30.         double profit = sumAllDays - expenses;
  31.  
  32.         System.out.printf("%.2f", profit);
  33.  
  34.  
  35.  
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement