maroon1
New Member
[FONT=verdana, arial, helvetica] Hi
[/FONT][FONT=verdana, arial, helvetica] I'm novice in programming
I want some to tell how can I reset the value of string when it is defined.
Sorry for my bad english, but I mean how can I remove the defintion from a string when it is defined
[/FONT][FONT=verdana, arial, helvetica]I will give this part of a program as an example
while (X>0)
{
System.out.print("Enter the name of the Item:");
item=input.nextLine();
System.out.print("Enter the value of the item: ");
value = input.nextDouble();
earning = value + 200 + (((9*value)/100));
System.out.printf("You have earned %.2f\n",earning);
}
[/FONT][FONT=verdana, arial, helvetica]The problem in this program is that I can input the name of the item for the first time only, after that I can't input the name.
I think it skips the line that says item=input.nextLine(); after the first loop
So, can someone tell me how can I input the name of the item without any limits. I want to write the name of the item in every loop.
Thanks in advance[/FONT]
[/FONT][FONT=verdana, arial, helvetica] I'm novice in programming
I want some to tell how can I reset the value of string when it is defined.
Sorry for my bad english, but I mean how can I remove the defintion from a string when it is defined
[/FONT][FONT=verdana, arial, helvetica]I will give this part of a program as an example
while (X>0)
{
System.out.print("Enter the name of the Item:");
item=input.nextLine();
System.out.print("Enter the value of the item: ");
value = input.nextDouble();
earning = value + 200 + (((9*value)/100));
System.out.printf("You have earned %.2f\n",earning);
}
[/FONT][FONT=verdana, arial, helvetica]The problem in this program is that I can input the name of the item for the first time only, after that I can't input the name.
I think it skips the line that says item=input.nextLine(); after the first loop
So, can someone tell me how can I input the name of the item without any limits. I want to write the name of the item in every loop.
Thanks in advance[/FONT]
Last edited: