Skip to content

Instantly share code, notes, and snippets.

@MP-C
Created June 4, 2022 15:32
Show Gist options
  • Save MP-C/070c15768932fbef4975978a0a3e8874 to your computer and use it in GitHub Desktop.
Save MP-C/070c15768932fbef4975978a0a3e8874 to your computer and use it in GitHub Desktop.
Java 02 Algrithmique
public class CandyCount {
public static void main(String[] args) {
double realMoney = 12.4;
double realPrice = 1.2;
int candies = 0;
if (realMoney > 0 && realPrice > 0){
while ((realMoney - realPrice) >= 0) {
candies = candies + 1;
realMoney = realMoney - realPrice;
}
System.out.println(candies);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment