Why does this program stop running?

Posted by designloper on Stack Overflow See other posts from Stack Overflow or by designloper
Published on 2010-06-01T22:21:37Z Indexed on 2010/06/01 22:33 UTC
Read the original article Hit count: 135

Hi everyone....I am developing a card making system...nothing fancy.

Right got this far but program now stops running with no error when running after the first card sample i.e. " Enter 'OK' if this card is OK, otherwise enter an alternative border character: + ".

Any suggestions Java Masters?

    //Ask user for input
 //makes use of print line method
 System.out.println("Enter name: ");

 //took the variables
 //called the object of the scanner 'cardOrder'
 //and use the Scanner objects method '.nextLine'
 //to read the next line of the input
 firstName = cardOrder.nextLine();
 mInitial = cardOrder.nextLine(); 
 lastName = cardOrder.nextLine();

 //Print out the "Here is a sample card" + the first name, middle initial and last name
 System.out.println("Here is a sample card: \n\n"  + firstName + mInitial + lastName + "**************" +
   "**************" + firstName + mInitial + lastName + "\n*                                *" + 
   "\n*" + "      " + firstName + mInitial + lastName +  "                       *"
   + "\n*                                *\n" + firstName + mInitial + lastName +"**************" +
   "**************" + firstName + mInitial + lastName + "\n");

 //Ask user is the card is OK to proceed to order query or if they want an alternative border character: +
 System.out.println("Enter 'OK'  if this card is OK, otherwise enter an alternative border character: + ");

 //Check if user entered "OK" and store it in var optionA
 optionA = cardOrder.nextLine();

 //test


 if (a == optionA){
  System.out.println("\nHow many cards would you like? ");

     cardsOrdered = cardOrder.nextInt();

     equals = (int) (cardPriceA * cardsOrdered);

  System.out.println("The price of " + cardsOrdered + " cards"+ " is £" + equals + ".\n");

  System.out.println("No Discount given.");

  }
 else if(b == optionA) {
  //Print out the "Here is a sample card" + the first name, middle initial and last name
  System.out.println("Here is a sample card: \n\n"  + firstName + mInitial + lastName + "++++++++++++++" +
    "++++++++++++++" + firstName + mInitial + lastName + "\n+                                +" + 
    "\n+" + "      " + firstName + mInitial + lastName +  "                       +"
    + "\n+                                +\n" + firstName + mInitial + lastName +"++++++++++++++" +
    "++++++++++++++" + firstName + mInitial + lastName + "\n");

  //Ask user is the card is OK to proceed to order query or if they want an alternative border character: +
  System.out.println("Enter 'OK'  if this card is OK, otherwise enter an alternative border character: OK ");
  //Check if user entered "OK" and store it in var optionA
  optionA = cardOrder.nextLine();
  if (a == optionA){

   System.out.println("\nHow many cards would you like? ");

      cardsOrdered = cardOrder.nextInt();

      equals = (int) (cardPriceA * cardsOrdered);

   System.out.println("The price of " + cardsOrdered + " cards"+ " is £" + equals + ".\n");

   System.out.println("No Discount given.");

   }
 }
 else if (c == optionA) {//Print out the "Here is a sample card" + the first name, middle initial and last name
  System.out.println("Here is a sample card: \n\n"  + firstName + mInitial + lastName + "**************" +
    "**************" + firstName + mInitial + lastName + "\n*                                *" + 
    "\n*" + "      " + firstName + mInitial + lastName +  "                       *"
    + "\n*                                *\n" + firstName + mInitial + lastName +"**************" +
    "**************" + firstName + mInitial + lastName + "\n");

  //Ask user is the card is OK to proceed to order query or if they want an alternative border character: +
  System.out.println("Enter 'OK'  if this card is OK, otherwise enter an alternative border character: + ");

  //Check if user entered "OK" and store it in var optionA
  optionA = cardOrder.nextLine();


  if (a == optionA){

   System.out.println("\nHow many cards would you like? ");

      cardsOrdered = cardOrder.nextInt();

      equals = (int) (cardPriceA * cardsOrdered);

   System.out.println("The price of " + cardsOrdered + " cards"+ " is £" + equals + ".\n");

   System.out.println("No Discount given.");

  }


 }

© Stack Overflow or respective owner

Related posts about java

Related posts about oop