• 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
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

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: 73760
332
  • 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.
 
Rancher
Posts: 184
7
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: 73760
332
  • 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: 73760
332
  • 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.
 
Acetylsalicylic acid is aspirin. This could be handy too:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic