Hi Every one,
i'm new to java programming
and while i was trying to make the following programm a problem occured
the problem is that the statment
"Please choose the item you want to buy"
repeats twice every time the loop repeats
so please anyone give me a hand to fix this
thanx
Code:import java.util.Scanner;
public class Store2
{
/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
String item1 = "Adidas shoes";
String item2 = "Nike shirt";
String item3 = "Anta wallet";
String choose = "";
Scanner input = new Scanner(System.in);
String dicide = "";
double total2 = 0;
int qty1=0;
int qty2=0;
int qty3=0;
double total;
System.out.printf("We have three items\n1-%s\n2-%s\n3-%s\n\n",item1,item2,item3);
while((!choose.equals("stop")))
{
System.out.print("Please choose the item you want to buy: \n");
choose = input.nextLine();
if((choose.equals("1")))
{
System.out.printf("You have chose \"%s\"\n",item1);
System.out.printf("Are you sure u want to buy \"%s\"?\n",item1);
dicide = input.nextLine();
if(dicide.equals("yes"))
{
System.out.println("How many pieces you wanna buy?");
qty1 = input.nextInt();
System.out.println("the price per piece is $229.88");
System.out.printf("The total price is: $%.2f\n",total = qty1*229.88);
total2 = total2 + total;
}
}
}
}
}

