• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Program to test a palindrome

 
Ranch Hand
Posts: 130
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a programming assignment I submitted for grading but I want it to be reviewed so I can learn and perfect  the code.

I have not written any unit test code to test the scope of the code...
I will be glad to have your say on it.

I have included the specification of the program as a comment in the first line.
Thank you...
 
Marshal
Posts: 79969
396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should always post the exact code; what you posted won't compile.

You should write a descriptive comment before each subroutine, saying what it does.

Which you haven't done. Look at line 32.
Line 61 is indented incorrectly.
Lines 54‑56 show several formatting errors; I shall leave you to count them.

What does line 52 mean? Why are you saying routines and subroutines, which are not Java® words? Please explain your choice of loop types.
 
Bartender
Posts: 209
14
Mac OS X IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just wanted to add that StringBuilder has built in method reverse()
 
Campbell Ritchie
Marshal
Posts: 79969
396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can also use the StringBulder#insert() method at position 0.
 
Kelvin Okornoe
Ranch Hand
Posts: 130
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the exact code of the program, It should be able to compile


Thanks for the comments, I will go ahead and make the changes and report back...
Thank you
 
Campbell Ritchie
Marshal
Posts: 79969
396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it does compile; sorry for my mistake. The fact that you managed to make me see a spurious compiler error denotes another error in the code, I am afraid. I can hardly think of a worse variable name in this situation than reserve, which is unnecessary anyway.
 
joke time: What is brown and sticky? ... ... ... A stick! Use it to beat this tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic