vendredi 22 septembre 2017

convert int to boolean issue in Java

For my class, I have to obey certain rules such as keeping the assigned variables and not adding anymore. We are creating a sales program for buying phones and accessories. This assignment, more or less, challenges us to use if/else statements. I have a spot to determine if the entered amount of phone accessories is a negative number to reject and force user to buy 1 of each item then proceeds to shipping info. I'm stuck on defining the outcome of if the user doesn't want any accessories. If this happens the user will type 0 as an integer to tell program they want none. Therefore, once all three accessories (case, car mount, screen protector) have been declined, the final resulting receipt will display "none" under the accessories portion instead of a total concatenated amount with names. I tried using an if statement

if(enteredQuantity=0){
accessoriesChosen="none";
accessoriesTotal=0;
}

The issue with this is my IDE is telling me that I need to convert the int type to boolean, which has never happened before. We aren't taught to convert to boolean.

Aucun commentaire:

Enregistrer un commentaire