Java Practice
2 posters
Horizons :: Development :: Java General
Page 1 of 1
Java Practice
So, since we are complete beginners at java why don't we set some practice goals on simple programs, try to create a program that will achieve the goal and compare and discuss.
First problem.
30 cookies are need to feed a part. A tray can bake 5 cookies at a time. How many trays do you need to feed the party?
First problem.
30 cookies are need to feed a part. A tray can bake 5 cookies at a time. How many trays do you need to feed the party?
Re: Java Practice
6 trays worth of cookies.Also, the trays themselves cannot feed the party.
You and your clever wording.....
You and your clever wording.....
Nero- Posts : 38
Join date : 2011-09-10
Re: Java Practice
Great you know basic arithmetic.
But the point of this excercise is to create a program that'll will find the answer for you.
I tried it quick, it's not working right, now we can discuss it. That's how these excericse works.
But the point of this excercise is to create a program that'll will find the answer for you.
- Code:
import static java.lang.System.out;
class HowManyCookies {
public static void main(String args[]) {
int cookies = 1;
int cookiesPerTray = cookies/5;
int cookiesToFeedEveryone = 30;
do {
cookies++;
out.println(cookiesPerTray + " trays to feed everyone");
} while(cookies<cookiesToFeedEveryone);
}
}
I tried it quick, it's not working right, now we can discuss it. That's how these excericse works.
Horizons :: Development :: Java General
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|