-
jump use
Hi all,
I am collecting some input for keyboard.
I am doing some operation on the acquired data.
Things are fine till this but problem is that I wish to reuse the code I put for data collection when some condition go wrong.
I have not much frequent user of jump, so I am unable to do the same can any one help me for this
Regards,
Tarun
-
Re: jump use
Hey You can use label by using Continue
-
Re: jump use
Thanx murli for reply but jump with continue is an control loop statement I tried but I am not clear how to use continue and label in a loop statement.
And whether it is possible to do in without looping :confused:
regards
Tarun
-
Re: jump use
Please post your complete Problem description..
-
Re: jump use
I am trying to get selection from user from keyboard…….
For some arithmetic operation as selected by the user……..
After doing some operation
I wish to ask again the user for new selection.
As I have already put the code for user input and arithmetic operations I wish I could go back for user to input again or to quit…….
Say I ask…..
“Please input x for multiply z to divide or e to exit.”
If user give input x
I do multiply operation on the data I collected before
Display the output and ask again
“Do you wish some other operation y to continue or n to exit”
If user input is y I go back to the line
“Please input x for multiply z to divide or e to exit.” Again
regards
Tarun
-
Re: jump use
Your Problem statement is not clear for me but I will try to suggest you as per my understanding of your problem.
For above mention case no need to use labels you can mange simply by writing the while and dowhile loops
efficiently.
For reference consider below template of code
char ch;
Scanner sc=new Scanner(System.in);
do
{
/********************
*********************
Add your input statements
Here read data using scanner object
for int using sc.nextInt()
for string using sc.next();
for double usinf sc.nextDouble();
and perform operations
********************
********************
*********************
*********************/
System.out.println("Press Y to Continue or N to Quit");
ch=sc.next();
}while(ch.compareToIgnoreCase(yes)==0)
I hope above block will helpful for you.
-
Re: jump use
thanx for reply again...
Hope it will do.....:o