Fix Java program with arrays

15 pts.
Tags:
Java
I have a pizza menu program. Therefore, I have 8 cases (in my switch case) in my main menu, out of which 7 cases work properly but my case 8 isn't working. It's coming the way catch exception comes(for a second and gone). My case 8: contains d bill. Now how can I fix this? It's not working with if else either.

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Subhendu Sen
    Please post your code, (the last one) and it may help to trace out the problem.
    118,290 pointsBadges:
    report
  • jodanny
    while(true)
    { 
    try
    {
    System.out.println("\u000c");
    System.out.println("1. Soups\n2.Garlicbread\n3.Pasta\n4.Veg Pizza\n5.Non veg pizza\n6.drinks\n7.desserts\n8.bill");
    int ch=obj.nextInt(); obj.nextLine();
    } 
    catch (Exception e)
    { System.out.println("\u000c");obj.nextLine(); System.out.println("Enter a digit"); continue;
    }
    switch(ch)
    { case 1:soups();break;
    case 2: gb();break;
    case 3:pasta();break;
    case 4:vp(); break;
    case 5: nvp();break;
    case 6: drinks(); break;
    case 7: dess(); break;
    case 8: bill(); break;
    default:System.out.println("\u000c"); System.out.println("invalid choice");
    }
    15 pointsBadges:
    report
  • wseng92
    Please post your bill method. 
    275 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: