Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class BiscuitsFactory {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int amountOfBiscuits = Integer.parseInt(scanner.nextLine());
- int workersCount = Integer.parseInt(scanner.nextLine());
- int otherProduce = Integer.parseInt(scanner.nextLine());
- int countDays = 1;
- int days = 30;
- int sum = 0;
- int countBiscuitsForDay = amountOfBiscuits * workersCount;
- sum = ImplementationMethod(countDays, days, sum, countBiscuitsForDay);
- System.out.printf("You have produced %d biscuits for the past month.%n", sum);
- if (sum >= otherProduce) {
- int diff = sum - otherProduce;
- double percentage = (diff * 1.00 / otherProduce) * 100;
- System.out.printf("You produce %.2f percent more biscuits.",percentage);
- }else {
- int diff = otherProduce - sum;
- double percentage = (diff * 1.00 / otherProduce) * 100;
- System.out.printf("You produce %.2f percent less biscuits.",percentage);
- }
- }
- private static int ImplementationMethod(int countDays, int days, int sum, int countBiscuitsForDay) {
- for (int i = 1; i <= days; i++) {
- if (countDays == 3) {
- sum += countBiscuitsForDay * 0.75;
- countDays = 1;
- continue;
- }
- countDays++;
- sum += countBiscuitsForDay;
- }
- return sum;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment