Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

JASdeep11 Group Title

Write a program that reads a whole number of up to nine digits and prints it in words. For example, the input 13247 ought to produce "thirteen thousand two hundred forty seven". i need a step-by-step explanation not the code and i am supposed use the switch statement

  • one year ago
  • one year ago

  • This Question is Closed
  1. the_me Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    which programming language?

    • one year ago
  2. bdean20 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    The first thing to look at is the limits. You need 9 digits. This means that your words need to go up to 999,999,999 or [Nine Hundred and Ninety Nine] Million, [Nine Hundred and Ninety Nine] Thousand, [Nine Hundred and Ninety Nine]. And in the repeated section, there's more repetition... [Nine] Hundred and Ninety [Nine] Hopefully you see that you'll only need to store the words of the following types "one", "two", "three", ... "eleven", "twelve", "thirteen", ... [special case] "twenty", "thirty", "forty", ... "hundred", "thousand", "million", ... Once you have them stored, you just need to print them in the right order. This is where the switch comes in. For example: switch(number){ case 1: //print "one" break; } You may need multiple switches, depending on how you structure it.

    • one year ago
  3. JASdeep11 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    c++

    • one year ago
  4. teic85 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    What does a switch do?

    • one year ago
  5. Pradius Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    lol is this class about AI??

    • one year ago
  6. bdean20 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    A switch is used in place of lots of ifs and elses, in practice. Instead of: if (number == 1){ //do something } else if (number==2){ //do something } You do this: switch(number){ case 1: //if number is 1, execute this code break; case 2: //if number is 2, execute this code break; } You'll potentially want to use both in different circumstances. A switch is definitely easier for multiple situations, especially if you want to execute the code for two options in only some of the cases (if you don't include break at the end of a case, it will run through until the end of the switch or the next break statement).

    • one year ago
  7. teic85 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    @bdean20, thanks for the explanation. I don't fully understand it, because I know nearly nothing about computer science and programming languages. I've been trying to find sources online to learn about these topics: Open Study, Udacity, YouTube, Khan Academy; but, so far I've had a lot of trouble understanding because I am wholly unfamiliar.

    • one year ago
  8. JASdeep11 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    @bdean20 on youtube look up thenewboston and he has some preety good tutorial for c++, python, Java, and some others. I know that for Java it has helped me out a lot, and we use it for my class.

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.