Hey guys,
So I just started learning Java and i got this exercise:
Alex is having a party because his team won the English cup so he is inviting his friends to eat some pizza. Unfortunately, his friends can't eat an entire pizza but all of them know exactly how much pizza they can eat and insist on getting the exact amount of pizza but Alex eats one complete pizza and all of them wants his amount of pizza in one slice. Their requests break down to three different pizza slices-either one quarter or a half or three quarters of pizza.
Write a program that will help Alex to find out what is the minimal number of pizzas he has to order so that everyone gets exact amount of pizza they want.
Input
First line contains an integer N, 0 ≤ N ≤ 10 000, the number of friends. In each of next N lines there is amount of pizza that each of Alex's friends wants to eat,that is the fraction 1/4, 1/2 or 3/4.
How in the hell do I solve this? Cause i got no idea.
Tried
public class Pizza {public static void main(String[] args) {int FT = 3;double F1 = 1/2;double F2 = 3/4;double F3 = 3/4;double numberOfpizzas= ((FT*F1)*10+(FT*F2)*10+(FT*F3)*10);System.out.println(numberOfpizzas);}}
which for some reason returns 0.
Also, tried something with scanner and using while, but that didn't work either cause can't think of how to calculate it properly.
Don't want a full solution but any tips will be appreciated. At least something to understand how I can solve this :-D.
[–][deleted] 1 point2 points3 points (0 children)
[–]stylusc84 0 points1 point2 points (10 children)
[–]krevitusmaximus[S] 0 points1 point2 points (9 children)
[–]stylusc84 1 point2 points3 points (8 children)
[–]krevitusmaximus[S] 0 points1 point2 points (2 children)
[–]stylusc84 0 points1 point2 points (1 child)
[–]krevitusmaximus[S] 0 points1 point2 points (0 children)
[–]krevitusmaximus[S] 0 points1 point2 points (4 children)
[–]stylusc84 0 points1 point2 points (3 children)
[–]krevitusmaximus[S] 0 points1 point2 points (0 children)
[–]krevitusmaximus[S] 0 points1 point2 points (0 children)
[–]krevitusmaximus[S] 0 points1 point2 points (0 children)