Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- double biscPerDay = Integer.parseInt(scan.nextLine());
- int workers = Integer.parseInt(scan.nextLine());
- int compBiscs = Integer.parseInt(scan.nextLine());
- double tempBiscsPerDay = biscPerDay;
- int ourBiscsTotal = 0;
- double percent = 0;
- boolean greater = true;
- for (int i = 1; i <= 30; i++) {
- biscPerDay = tempBiscsPerDay;
- if(i%3 == 0){
- biscPerDay = biscPerDay * 0.75;
- }
- ourBiscsTotal +=Math.floor((biscPerDay*(double)workers));
- }
- double difference = 0;
- if(ourBiscsTotal > compBiscs){
- difference = ourBiscsTotal - compBiscs;
- percent = difference/compBiscs*100;
- }
- else{
- difference = compBiscs - ourBiscsTotal;
- percent = difference/compBiscs*100;
- greater = false;
- }
- System.out.println("You have produced " + ourBiscsTotal + " biscuits for the past month.");
- if(!greater){
- System.out.printf("You produce %.2f percent less biscuits." , percent);
- }
- else {
- System.out.printf("You produce %.2f percent more biscuits." , percent);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement