Results 1 to 5 of 5

Thread: A simple do/while/loop structure i'm having trouble with.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2011
    Posts
    17

    A simple do/while/loop structure i'm having trouble with.

    I have to create an application that lets a user enter as much grades he wants. The grades are between 0 and 100 and they can't be negative. Whenever the user type -1, the application is done and it shows the average of the grades, the lowest and the highest grades.

    I absolutly have no idea where to start but i must be using loop/do/while.

    I'm willing to send 5$ through paypal if you can guide me into the right direction =D

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: A simple do/while/loop structure i'm having trouble with.

    We don't do homework (and somebody would have to be mighty hard up to do anything for $5), but we are willing to help out if you start off. You might start by listing the steps that the program will have to perform in order. That doesn't mean the question, but the things that the program will have to be able to do to work as described. For instance, it obviously must ask the user for some input. Does it need to do anything after that? How will you get that input (most classes cover only one or two ways, so you probably have very limitted options here)? What will you do with that input once you get it? And so forth.
    My usual boring signature: Nothing

  3. #3
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: A simple do/while/loop structure i'm having trouble with.

    The next link would be good to start --> http://www.startvbdotnet.com/language/loops.aspx
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Sep 2011
    Posts
    17

    Re: A simple do/while/loop structure i'm having trouble with.

    Thanx for the links

    Ill post my results later

  5. #5
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,390

    Re: A simple do/while/loop structure i'm having trouble with.

    Don't worry about the money ... but:

    vb Code:
    1. Dim Results As New List(Of Integer)
    2.         Console.WriteLine("Enter Results (-1 when done):")
    3.         Do
    4.             Dim strResult = Console.ReadLine()
    5.             Dim CurrentResult As Integer
    6.             If Integer.TryParse(strResult, CurrentResult) Then
    7.                 If CurrentResult = -1 Then
    8.                     'show results
    9.                     Console.Clear()
    10.                     If Results.Count > 0 Then
    11.                         Console.WriteLine("Average: " & Results.Average)
    12.                         Console.WriteLine("Highest: " & Results.Max)
    13.                         Console.WriteLine("Highest: " & Results.Min)
    14.                         Console.ReadKey()
    15.                     End If
    16.                     Return
    17.                 Else
    18.                     Results.Add(CurrentResult)
    19.                 End If
    20.             Else
    21.                 Console.WriteLine("You must enter an integer!")
    22.             End If
    23.         Loop

    Kris

Posting Permissions

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



Click Here to Expand Forum to Full Width