Question on code
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Thread: Question on code

  1. #1
    Join Date
    Dec 2008
    Posts
    4

    Unhappy Question on code

    I have some questions I have a answer for a college test and need some help on a couple I am stuck on.

    #1 Write code that declares a string array with three elements, and then stores your first, middle, and last name in the arrays elements.

    #2 Write a Do While loop that uses an input box to get a number from the user. The number should be mulitplied by 10 and the result stored in the variable product. The loop should iterate as long as product contains a value less than 100. Use intNumber and intProduct.


    Please help me write this code. Thank you

  2. #2
    Join Date
    Mar 2002
    Location
    NY, USA
    Posts
    12,097

    Re: Question on code

    1) Update your profile to enable prive messageing and viewing of signatures.

    2) Read the link in my signature regarding homework.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009
    In theory, there is no difference between theory and paractice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  3. #3
    Join Date
    Dec 2008
    Posts
    4

    Re: Question on code

    I am just needing help. Im not here to argue with anyone and im not trying to cheat anyone. I'm not even wanting to become a programmer it was just required course that I had to take but dont really need. Thanks and any help would be great.

  4. #4
    Join Date
    Mar 2002
    Location
    NY, USA
    Posts
    12,097

    Re: Question on code

    Quote Originally Posted by jamedawg32 View Post
    I am just needing help. Im not here to argue with anyone and im not trying to cheat anyone. I'm not even wanting to become a programmer it was just required course that I had to take but dont really need. Thanks and any help would be great.
    Then follow the instructions for getting help with homework.

    It is available both in my signature, and as a FAQ.

    When YOU post your best effortys, and ask SPECIFIC questions, then people here will help. We do not DO homework.

    If you want someone to do your work for you (), you can pay them on sites such as rentacoder.com
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009
    In theory, there is no difference between theory and paractice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  5. #5
    Join Date
    Dec 2008
    Posts
    4

    Re: Question on code

    ok I will post what I have and see if you think it is ok. If you dont mind.

    #1. Write a Do While loop that uses an input box to get a number from the user. The number should be mulitplied by 10 and the result stored in the variable product. The loop should iterate as long as product contains a value less than 100. Use intNumber and intProduct.

    #1 Answer

    Dim names(2) As String
    names (0) = "Jamie"
    names(1) = "Andrew"
    names(2) = "Foster"

    #2. Suppose you need to store information about 12 countries. Declare two arrays that may be used in parallel to store the names of the countries and there populations. Use the underlined words for any array names.

    #2 Answer

    Dim strCountries (11) As String
    Dim strPopulations (11) As String
    For intCount 0 to 4
    lstCountry.Items.Add(“Country: “ strCountries(intCount) “ Population: “ strPopulation(intCount))

    #3. An event procedure named btnShow_Click must add numbers 1 through 20 to a list box named 1stNumbers. Write the code.

    #3 Answer

    1stNumbers.items.add (intCount)
    Next intCount

    #4. Write a Do While loop that uses an input box to get a number from the user. The number should be mulitplied by 10 and the result stored in the variable product. The loop should iterate as long as product contains a value less than 100. Use intNumber and intProduct.

    #4. Answer

    Dim intNumber As Integer
    Dim intProduct As Integer
    Do
    intNumber = CInt(InputBox("Enter A Number"))
    intProduct = intNumber * 10
    Loop While intProduct < 100



    Look ok??? please help and thank you

  6. #6
    Join Date
    Jan 2006
    Location
    Pearl of the orient
    Posts
    303

    Re: Question on code

    #1 and #4 are the same?

  7. #7
    Join Date
    Dec 2008
    Posts
    4

    Re: Question on code

    Sorry, question #1 should be

    Write code that declares a string array with three elements, and then store your first, middle, and last name in the arrays elements.

    Answer


    Dim names(2) As String
    names (0) = "Jamie"
    names(1) = "Andrew"
    names(2) = "Foster"

  8. #8
    Join Date
    Jan 2006
    Location
    Pearl of the orient
    Posts
    303

    Re: Question on code

    #1 and #4 seem correct to me. Could you clarify your answers on #2 and #3?

  9. #9
    Join Date
    Mar 2002
    Location
    NY, USA
    Posts
    12,097

    Re: Question on code

    Code:
    lstCountry.Items.Add(“Country: “ strCountries(intCount) “ Population: “ strPopulation(intCount))
    Does that COMPILE????
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009
    In theory, there is no difference between theory and paractice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  10. #10
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,961

    Re: Question on code

    It will help you greatly if you TYPE THE CODE IN YOURSELF, and then press the F5 key, to see the output (if it compiles)

    It looks like you skimmed the back of chapter 3 expecting to pick up on 6 weeks worth of courses.

    I wish someone would do that for me, so I can take a long vacation...
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  11. #11
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,722

    Re: Question on code

    It looks like numbers two and three are merged together:
    the for-loop of #2 surely must have its own Next statement, as well as the #3 loop must get its own for-statement.

    Also check on the syntax of the for-loop. It is nearly correct. Only one character missing.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center