• Post Reply Bookmark Topic Watch Topic
  • New Topic

what i have done wrong in this code  RSS feed

 
Vinamra Bali
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have just started to learn about static methods but can not make this programme work an help
 
Liutauras Vilda
Sheriff
Posts: 4917
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vinamra Bali,

I've added for you code tags, now is the way easier to read your code.
Please check how to UseCodeTags <- link.

Could you provide a bit more details about your existing problem.
When you cannot make it run, what does that mean: getting error during the run? cannot compile it and run it because of syntax error/-s? might getting unexpected results?
 
Ganish Patil
Ranch Hand
Posts: 529
19
Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Netbeans IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please with code also mention what sort of errors your getting. We need to know whether code compiles or runs successfully or not, be more specific so would get thorough solution
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
Stephan van Hulst
Saloon Keeper
Posts: 7974
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are comparing p in a while condition, but it never actually changes its value.

You can clean up this code by using proper capitalization (type names should start with a capital letter, and variable names should start with a lowercase letter), using descriptive names (for instance, a method called askUserForDouble(String question)) and using string builders and format strings to construct messages:


I realize you're just starting, but please remember the following if you want a successful career in programming. Never use floating point types for currency. Your variables should be of type BigDecimal instead.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!