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

Help on a program

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there! I'm a beginner at java and I am completely lost at this! I'm trying to pass this class and I need massive help with programs! Can someone please help me with this? I HAVE NO IDEA HOW TO DO THIS!!!

1.) Before each significant step, provide a comment explaining the step (do not comment
every line of code).

2.) The input is a String. It is recommended you immediately convert this String to
uppercase since 1-800-flowers and 1-800-FLOWERS would both display 1-800-
3569377 as the phone number.

3.) You MUST use a for-loop to step through phoneNumberStr.

4.) Within the for-loop body, convert only the letters to their equivalent number using the
following algorithm:
a. If the current character of phoneNumberStr is an uppercase letter, call the
method getNumber to determine the number and append (or concatenate) to
phoneNumber. Note that to check if the character is a letter consider the
ASCII range of uppercase letters.

For example, if(phoneNumberStr.charAt(i) == 65) is true when the character
at index i is A.

Also, recall that when considering characters use single quotes – ‘A’
b. If the current character of phoneNumberStr is NOT a letter, you will need to
create a one-character substring and then append/concatenate this substring to
phoneNumber
c. Output the phoneNumber

5.) Include appropriate hypens to the actual phone number.
That is, 1-800-flowers or 1800FLOWERS would display the phone number as
1-800-356-9377

Thanks for your time!!!
 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dylan, welcome to Java Ranch! You've come to the right place to learn about Java programing. Unfortunately, you haven't taken quite the right approach. We won't do your homework for you. That wouldn't really help you anyway, because you're taking the class to learn, not just to pass, right?

Is this your first assignment? It seems to be assuming you have a basic knowledge of Java programing already. Well, anyway, start small. Try to get one small part of it working, and if you get stuck, come back with a specific question and we'll be happy to help.
reply
    Bookmark Topic Watch Topic
  • New Topic