JAVA programming, please help
/**
* Write the method named makeBricks().
*
* We want to make a row of bricks that is goal
* inches long. We have a number of small bricks
* (1 inch each) and big bricks (5 inches each).
* Return true if it is possible to make the
* goal by choosing from the given bricks.
*
* Examples:
* makeBricks(3, 2, 9) returns false
* makeBricks(1, 4, 12) returns false
* makeBricks(2, 1000000, 100003) returns false
* makeBricks(3, 1, 8) returns true
* makeBricks(3, 1, 9) returns false
* makeBricks(3, 2, 10) returns true
*
*
* @param small number of small bricks.
* @param big number of big bricks.
* @param goal number of bricks desired in row.
* @return true if possible with available bricks.
*/
public boolean makeBricks(int small, int big, int goal)
{
// TODO - Write the makeBricks method here
}
Please let me know if you have any doubts or you want me to modify the answer. And if you find this answer useful then don't forget to rate my answer as thumps up. Thank you! :)
public class MakeBricks {
public static boolean makeBricks(int small, int
big, int goal) {
if (goal == 0) {
return true;
} else if (goal != 0
&& small == 0 && big == 0) {
return false;
}
if (big != 0) {
int times = goal / 5;
if(times > big){
times = big;
}
goal = goal - (times * 5);
big = 0;
}else if(small !=
0){
goal = goal - small;
if(goal < 0){
goal = 0;
}
small = 0;
}
return makeBricks(small
,big, goal);
}
public static void main(String[] args)
{
System.out.println(makeBricks(3, 2,
9));
System.out.println(makeBricks(1, 4,
12));
System.out.println(makeBricks(2,
1000000, 100003));
System.out.println(makeBricks(3,1,8
));
System.out.println(makeBricks(3, 2,
10));
System.out.println(makeBricks(3, 1, 9));
}
}
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

JAVA programming, please help /** * Write the method named makeBricks(). * * We want to...