mercredi 30 septembre 2015

If-else statements, always running

I am working on making a coffee ordering system. It takes inputs from users and calculates the price of their coffee. One of the inputs asked for is "syrupshots". This code always makes syrupshots = 3 even if the user properly chose a number according to the size of their coffee.

//if size == tall   syrup shots <=3
if(size == 1 && syrupshots < 1 || syrupshots > 3)
{
    syrupshots = 3;
}
//else if size == medium     syrup shots <=5
else if(size == 2 && syrupshots < 1 || syrupshots > 5)
{
    syrupshots = 3;
}
//else if size == Venti        syrup shots <=7
else if(size == 3 && syrupshots < 1 || syrupshots > 7)
{
    syrupshots = 3;
}
System.out.println(syrupshots);

I am not sure why syrupshots is always = 3 no matter what.

Aucun commentaire:

Enregistrer un commentaire