I am trying to figure out why it prints "What kind of flower would you like?" twice after doing the initial "y". The rest of the program seems to run fine except for it printing that line out twice.
import java.text.*; import java.util.Scanner; public class FlowerCounter{ public static void main(String[] args){ DecimalFormat df = new DecimalFormat("0.00"); Scanner in = new Scanner(System.in); //declare and create an array of ten rectangles //declare and create an int array of ten elements //int[] intArr = new int[10]; String[] flowerArray = {"petunia", "pansy", "rose", "violet", "carnation", "lily", "poppy", "daisy", "tulip", "hydrangea", "none"}; double[] flowerPrice = {.50, .75, 1.50, .75, .85, 1.25, 2.15, .85, 2.75, 1.30, 0.00}; char Answer = 'y'; String flower; int i = 0; int t = 0; double cost = 0.0; int stems = 0; double stemcost = 99.0; System.out.print("Do you want to purchase flower (Y or N)?"); Answer = in.next().charAt(0); System.out.println(); while(Answer == 'y'){ System.out.print("What kind of flower would you like?"); flower = in.nextLine(); System.out.println(); System.out.println(); stemcost = 99.0; for(i =0; i<=10; i++){ if (flower.equalsIgnoreCase(flowerArray[i])){ System.out.print("How many flowers would you like?"); stems = in.nextInt(); cost = cost + (flowerPrice[i]*stems); stemcost = (flowerPrice[i]*stems); System.out.println(flowerArray[i]+": "+ stems + " at $"+ df.format(flowerPrice[i])+ " will cost $"+ df.format((flowerPrice[i]*stems))); System.out.println(); System.out.println(); System.out.println(); Answer = '\0'; System.out.print("Do you want to purchase flowers (Y or N)?"); String tstring = in.next(); char temp2 = tstring.charAt(0); Answer = temp2; System.out.println(i); }//end if //else if (flowerPrice[i]==0.00){System.out.println(i);} //if(stemcost == 0) {System.out.println("Sorry we don't have that flower.");} }//end for }// end while System.out.println("The total cost is : $"+df.format(cost)); }//end class }//end main