I know that my code still has flaws (its a work in progress). But I got these couple errors and I don't understand why. Any help at all is appreciated thank you!!
theses are the errors
C:\Users\me\Documents\MailOrderEMH.java:27: error: variable numBoxes is already defined in method main(String[])
int numBoxes = Integer.parseInt(numBoxesString);
^
C:\Users\me\Documents\MailOrderEMH.java:70: error: bad operand types for binary operator '||'
while (enterAnother == "Y" || "y")
^
first type: boolean
second type: String
C:\Users\me\Documents\MailOrderEMH.java:102: error: incompatible types: String cannot be converted to int
( "Enter Number of Boxes: " );
^
3 errors
Tool completed with exit code 1
and here is the code
import javax.swing.JOptionPane; // Imports JOptionPane class.
public class MailOrderEMH
{
public static void main( String[] args )
{
// Declare string variables
String title;
String firstName;
String lastName;
String streetAddress;
String city;
String state;
String zip;
String numBoxesString;
int numBoxes;
int count = 1;
String enterAnother = "Y"; //INITILIZE the loop control variable
//get input values from user
numBoxesString = JOptionPane.showInputDialog
( "Enter Number of Boxes: " );
//Conver srring to integer
int numBoxes = Integer.parseInt(numBoxesString);
//get input values from user
title = JOptionPane.showInputDialog
( "What is your title ex. (Ms. Mr. Dr.) " );
//get input values from user
firstName = JOptionPane.showInputDialog
( "Enter First Name: " );
//get input values from user
lastName = JOptionPane.showInputDialog
( "Enter Last Name: " );
//get input values from user
streetAddress = JOptionPane.showInputDialog
( "Enter Street Address: " );
//get input values from user
city = JOptionPane.showInputDialog
( "Enter City: " );
//get input values from user
state = JOptionPane.showInputDialog
( "Enter State: " );
//get input values from user
zip = JOptionPane.showInputDialog
( "Enter Zip Code: " );
while (count <= numBoxes)
{
System.out.println( title + firstName + lastName );
System.out.println( streetAddress );
System.out.println( city + state + zip );
System.out.println( "Box" + count + "of" + numBoxes);
count = count + 1;
}
//get input values from user
enterAnother = JOptionPane.showInputDialog
( " Do you want to produce more labels? Y or N " );
while (enterAnother == "Y" || "y")
{
//get input values from user
title = JOptionPane.showInputDialog
( "What is your title ex. (Ms. Mr. Dr.) " );
//get input values from user
firstName = JOptionPane.showInputDialog
( "Enter First Name: " );
//get input values from user
lastName = JOptionPane.showInputDialog
( "Enter Last Name: " );
//get input values from user
streetAddress = JOptionPane.showInputDialog
( "Enter Street Address: " );
//get input values from user
city = JOptionPane.showInputDialog
( "Enter City: " );
//get input values from user
state = JOptionPane.showInputDialog
( "Enter State: " );
//get input values from user
zip = JOptionPane.showInputDialog
( "Enter Zip Code: " );
//get input values from user
numBoxes = JOptionPane.showInputDialog
( "Enter Number of Boxes: " );
}
// End program.
System.exit(0);
}
}