PROBLEM LINK:
Author: thvardhan
Tester: thvardhan
DIFFICULTY:
cakewalk
PREREQUISITES:
nothing
PROBLEM:
You have to calculate the percent chance of getting a diamond out of coal and gold.
QUICK EXPLANATION:
we simply do
double total=gold+diamond+coal;
if(total!=0){
double diamondChance=100*(diamond/total);
and print it.
EXPLANATION:
To calculate the percentage we first calculate the total items present by adding them all.
double total=gold+diamond+coal;
now we just check if its 0 if true we will print “No” else we calculate it.
if(total!=0){
double diamondChance=100*(diamond/total);
now we simply check if the chance is more than 50 if it is then we print “Yes” else “No”
if(diamondChance>50)
{System.out.println("Yes");}
else
{System.out.println("No");}