A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

write a method that returns true if it is possible to make a package with goal kilos of rice
Q:

write a method that returns true if it is possible to make a package with goal kilos of rice

0

Provided that you have a given number of small rice bags (1 kilo each) and big rice bags (5 kilos each), write a method that returns true if it is possible to make a package with goal kilos of rice.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

public Boolean packageRice(Integer big, Integer small, Integer goal) {
boolean result = false;
if (big * 5 >= goal) {
    if (small >= goal % 5)
        result = true;
} else {
    if (small >= goal - big * 5) {
        result = true;
    }
}
return result;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now