Advertisement
Guest User

Untitled

a guest
Mar 6th, 2018
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Ex3 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int raspQt = Integer.parseInt(scanner.nextLine());
  8. int strawQt = Integer.parseInt(scanner.nextLine());
  9. int cherryQt = Integer.parseInt(scanner.nextLine());
  10. int juiceAllowed = Integer.parseInt(scanner.nextLine());
  11.  
  12. double currentJuice = 0;
  13.  
  14. for (int i = 0; i <= raspQt ; i++) {
  15. for (int j = 0; j <= strawQt; j++) {
  16. for (int k = 0; k <= cherryQt ; k++) {
  17. currentJuice = (i * 4.5) + (j * 7.5) + (k * 15);
  18. if (currentJuice == juiceAllowed || currentJuice == juiceAllowed-1) {
  19. System.out.printf("%d Raspberries, %d Strawberries, %d Cherries. Juice: %.0f ml.", i,j,k,currentJuice);
  20. return;
  21. }
  22. }
  23. }
  24. }
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement