Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Ex3 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int raspQt = Integer.parseInt(scanner.nextLine());
- int strawQt = Integer.parseInt(scanner.nextLine());
- int cherryQt = Integer.parseInt(scanner.nextLine());
- int juiceAllowed = Integer.parseInt(scanner.nextLine());
- double currentJuice = 0;
- for (int i = 0; i <= raspQt ; i++) {
- for (int j = 0; j <= strawQt; j++) {
- for (int k = 0; k <= cherryQt ; k++) {
- currentJuice = (i * 4.5) + (j * 7.5) + (k * 15);
- if (currentJuice == juiceAllowed || currentJuice == juiceAllowed-1) {
- System.out.printf("%d Raspberries, %d Strawberries, %d Cherries. Juice: %.0f ml.", i,j,k,currentJuice);
- return;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement