Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int vendingMachineOne(double money, double cost, boolean hasChips){
- //variable names and meanings
- //money: the amount of money the person enters into machine (positive value)
- //cost: how much the bag of chips cost
- //hasChips: boolean that is true if the vending machine has the chips
- //giveChips: true if the vending machine dispenses chips to the person
- //giveRefund: true if the vending machine returns any money to the person.
- boolean giveChips, giveRefund; //declare the variables to assign
- //WRITE YOUR CODE IN THE SPACE BELOW
- //-------------------------------------------------------------------
- //-------------------------------------------------------------------
- //DO NOT CHANGE THE CODE BELOW THIS COMMENT
- if(giveChips){
- if(giveRefund){ return 1; } //chips and refund
- else { return 2; } //chips and no refund
- }
- else{
- if(giveRefund){ return 3; } //no chips and refund
- else{ return 4; } //no chips and no refund (will not happen)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement