• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Prices will not display

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Sheriff
Posts: 17405
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have your System.out.println() statement under the default case of the switch statement. That means it will only be executed if the package is not one of any of the cases above it. That is, if the package is A, B, or C, then the System.out.println() statement will NOT be performed. Only when it is NOT any of A, B, or C will it display something.
 
Junilu Lacar
Sheriff
Posts: 17405
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, the if-statements under each case are redundant. For example, for case 'A', you check if (inputPackage.equals('A'). Why? The case 'A' label already establishes that packages is in fact 'A' so why do you need to check it again?
 
Junilu Lacar
Sheriff
Posts: 17405
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another thing: look carefully at your if-statements on line 53 and 61. You have a very subtle bug on those two if-statements.  If you test your program thoroughly, you'll find that it's always charging extra fees for A and B.
 
Sheriff
Posts: 7123
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On line 48 the OP is switching on packages, which is an int, not a character.  This will be very confusing.  You probably want to switch on inputPackage.
 
Marshal
Posts: 77159
370
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Junilu Lacar wrote:. . . line 53 and 61. You have a very subtle bug . . . .

The error is so similar on those two lines that I suspect there has been copying'n'pasting going on. That shows why copying'n'pasting code is a bad idea.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic