Forums Register Login

indicated Nmubers before guests

+Pie Number of slices to send: Send
Question : Problem i want the output as
1.user Input
2.user Input
3.user Input
and so ON
i need number of Guests
I know this one is wrong but how can i do that .

+Pie Number of slices to send: Send
Campbell Ritchie you told me in one of my post that i should use



instead of

But when i use the first one error pop up or the program doesn't run as i expected
+Pie Number of slices to send: Send
 

Saad Zahoor wrote:I know this one is wrong but how can i do that .



One recommendation here is to *never* give up on moving forward.

You know it is wrong; so, what is the next step?  Can you figure out why is it wrong? Can you figure out what is causing it to be wrong? And of course, what can you change to get it closer to not being wrong?

Henry
+Pie Number of slices to send: Send
Let me think
+Pie Number of slices to send: Send
 

Saad Zahoor wrote:Campbell Ritchie you told me in one of my post that i should use . . .

I am quite sure I didn't tell you to use the ; in that line. A correctly‑written loop incorporating such code will work. The ; is incorrect in that location.

Read this. You have to tell us the details of the error you are suffering otherwise we can't help.
+Pie Number of slices to send: Send
I have tried every possible way to solve this but in vain .. i give up !
1
+Pie Number of slices to send: Send
I simple way of doing it would be to use a counter in this loop:

Declare and initialize a counter outside of the loop, use it to print the guest number, then increment it
+Pie Number of slices to send: Send
 

Saad Zahoor wrote:I have tried every possible way to solve this but in vain .. i give up !



I don't know why you gave up so easily (seriously, 19 minutes is really quick to give up in vain !!). Quite frankly, you were already headed in the right direction by using the for loop that took an index. The index would have been good to use as the counter.

Like I said, think about why it is wrong?, meaning what is missing?, and think about how to get there. Once you break it down to a counter (that was missing), then you can draw the conclusion that the for loop has an index, that also can be used as a counter.

[EDIT: and apologies for stepping on Knute, who answered minutes before me.]

Henry
+Pie Number of slices to send: Send
Your Help is really Appreciated . Henry Wong , Knute !
Now it is working as i want .




One thing i don't get about the method .Does Every method has its own local variable ? . Can't we access the same variable in multiple variable except for the class variable . I Want to save this info into the file and but can't access the variable

+Pie Number of slices to send: Send
Multiple Methods*
+Pie Number of slices to send: Send
 

Saad Zahoor wrote:Does Every method has its own local variable ?



Not sure what you mean here... You are the coder of your application, and hence, you declare the variables. And if you declare local variables, then it will be local variables...

If you want a variable to be accessed at a larger scope, then you need to declare them as such. This is what instance and static variables are for.

Henry
It means our mission is in jeapordy! Quick, read this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 403 times.
Similar Threads
While Loop Error
java.util.Scanner Problem
Feedback on polymorphism exercise
Help with code
Need help with a program that is sensing vowels and consonants
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 04:23:28.