Home > Archive > Java Help > February 2005 > help!!!!
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| answer5646 2005-02-23, 4:00 am |
| i am in a programming class and am new to the whole thing i am supposed to
write a program that was assigned by the teacher and i am 
1) Declare a variable called "marbles" that will store the number of
marbles in a can.
2) Declare a variable "lightIsOn" that can be used to keep track of
whether a light switch is turned on or not.
3) Use an array initializer to declare and initialize an array called
"numbers" that initially contains the values 43, 5, 99, 16, 0
4) Declare an array called "lunch" that can be used to store the
amount
of money you spend on your lunch each day for a month.
5) Declare an array called "lunchperday" that can be used to store
the amount of money each of your four children spend each day for
lunch for one month. The lunch money totals are stored by child,
by day (not a running total). This data should be organized as
a table, with the children as rows, and the days as columns.
6) Assign the value 38 to the variable "marbles".
7) Display the number of marbles in the can.
8) Add one to the variable "marbles".
9) Add one to "marbles" using a different syntax for the addition.
10) Add one to "marbles" using yet ANOTHER syntax for the addition.
11) Display the number of marbles in the can.
12) Compute twice the number stored in "marbles" and assign it to
a variable called "product".
13) Display the variable "product".
14) Turn the light switch on.
15) Have your program calculate the following: If you were to divide
your marbles evenly among your (hypothetical) four children, how
many
would they each receive?
16) Display the answer.
17) Calculate how many would be left over after divying up the
marbles?
18) Display the answer.
NOTE: On the following questions, remember how Java indexes arrays!
19) On the first day of the month, your first child was sick so he
did not spend any money for lunch. Make an assignment to
"lunchperday" to reflect this.
20) On the fifth day of the month, your four children are treated to
lunch by Grandma, who charges them a flat "five bucks a head".
Update "lunchperday" to reflect this.
21) On the tenth day of the months, your children are again treated
to lunch by Grandma who charges them as follows:
first child: 9.50
second child: 7.00
third child: 4.00
fourth child: 4.99
Update "lunchperday" to reflect this.
22) Using the "lunchperday" table, compute the average lunch
charge for day ten.
23) Display this answer.
24) Turn the light off!
25) Display the value of lightIsOn.
if anyone can help me with this, it would be greatly appreciated
| |
| Ryan Stewart 2005-02-23, 4:00 am |
| "answer5646" <jakspin02@yahoo.com> wrote in message
news:63ae75ff5267431d780081717fb83834@lo
calhost.talkaboutprogramming.com...
>i am in a programming class and am new to the whole thing i am supposed to
> write a program that was assigned by the teacher and i am 
> 1) Declare a variable called "marbles" that will store the number of
> marbles in a can.
>
[...]
You don't have *any* idea where to start? Do you know how to write a Hello World
program, i.e. a program that compiles and runs and will do just one basic task?
If not, check your textbook or look here:
http://java.sun.com/docs/books/tuto...tion/index.html
That's assuming you've got a development environment up and running. If you
don't have that yet, you'll probably want to start here instead:
http://java.sun.com/docs/books/tuto...java/index.html
Once you've got down the basic structure of a simple program, learn to declare
variables in it:
http://java.sun.com/docs/books/tuto...olts/index.html
Here's a hint, in case that's all you need to get started. In a method (like
your "main" method), you declare a variable like this:
<type> <name>;
Where <type> is the type of the variable, such as int, double, String, Object,
etc; and <name> is the name by which the variable will be known in your code,
like "x", "blah", or "purpleElephantWearingUnderpants".
In order to both declare a variable *and* give it an initial value at the same
time, use this:
<type> <name> = <initial value>;
| |
| klynn47@comcast.net 2005-02-23, 4:00 am |
| It looks like your teacher has spelled everything out for you. There's
nothing we could do except write the code for you.
| |
| Erwin Moller 2005-02-23, 4:02 pm |
| Hi answer5646,
You are lucky Ryan took the time to give you a friendly answer.
In general: Don't ask this group to do all your coding.
Only ask this group to help you with a specific problem.
This is a newsgroup, not a get-your-homework-done-for-free-group.
A friendly (really) word of advise:
Come here only to ask questions AFTER you tried yourself.
Show us that you tried yourself.
Tell us why you are stuck and what you do not understand.
Then ask a to-the-point question.
Most people in here, that are able to help you, have other things to do, and
will skip your posting when they get the impression you didn't try to solve
it yourself.
Now, get your nose back into your studybooks and start again.
You can do it, the assigment is not hard.
Good luck!
Regards,
Erwin Moller
| |
|
| On Tue, 22 Feb 2005 20:47:54 -0500, "answer5646" <jakspin02@yahoo.com>
wrote:
>i am in a programming class and am new to the whole thing i am supposed to
>write a program that was assigned by the teacher and i am 
What school do you attend and who's the teacher? I'd like to make sure
my kids avoid it.
--
now with more cowbell
|
|
|
|
|