Advertisement
BojidarDosev

zad1

Feb 16th, 2025
5
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5.  
  6. Scanner scan = new Scanner(System.in);
  7.  
  8. double biscPerDay = Integer.parseInt(scan.nextLine());
  9. int workers = Integer.parseInt(scan.nextLine());
  10. int compBiscs = Integer.parseInt(scan.nextLine());
  11.  
  12. double tempBiscsPerDay = biscPerDay;
  13. int ourBiscsTotal = 0;
  14. double percent = 0;
  15. boolean greater = true;
  16.  
  17. for (int i = 1; i <= 30; i++) {
  18. biscPerDay = tempBiscsPerDay;
  19. if(i%3 == 0){
  20. biscPerDay = biscPerDay * 0.75;
  21. }
  22. ourBiscsTotal +=Math.floor((biscPerDay*(double)workers));
  23. }
  24.  
  25. double difference = 0;
  26. if(ourBiscsTotal > compBiscs){
  27. difference = ourBiscsTotal - compBiscs;
  28. percent = difference/compBiscs*100;
  29. }
  30. else{
  31. difference = compBiscs - ourBiscsTotal;
  32. percent = difference/compBiscs*100;
  33. greater = false;
  34. }
  35.  
  36. System.out.println("You have produced " + ourBiscsTotal + " biscuits for the past month.");
  37. if(!greater){
  38. System.out.printf("You produce %.2f percent less biscuits." , percent);
  39. }
  40. else {
  41. System.out.printf("You produce %.2f percent more biscuits." , percent);
  42. }
  43. }
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement