Results 1 to 7 of 7

Thread: Hey..

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2004
    Posts
    6

    Hey..

    I am in class right now and I need to know how to get a random number from a float variable..

    Eg
    "Make a random program that stimulates a coin toss. Generate a random number, if the number is less than .5 it's a head and if its greater it's a tail."

    Please help

  2. #2

    Thread Starter
    New Member
    Join Date
    Sep 2004
    Posts
    6
    I also just got an error..

    C:\Graphic Programming\ConsoleApplication2\Class1.cs(23): The name 'userInput' does not exist in the class or namespace 'ConsoleApplication2.Class1'

    but I declared it..

    [QUOTE]using System;

    namespace ConsoleApplication2
    {
    /// <summary>
    /// Summary description for Class1.
    /// </summary>
    class Class1
    {
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main(string[] args)
    {
    string userResponce;

    Console.WriteLine("Enter either 1 or 5");

    userResponce = Console.ReadLine();
    userInput = Console.ReadLine();

    switch (userInput)
    {
    case "1":
    Console.WriteLine("I never liked one, try again.");
    break;
    case "2":
    Console.WriteLine("Nope, try again");
    break;
    case "5":
    Console.WriteLine("Good job!");
    break;
    default:
    Console.WriteLine("I didn't say {0}, you imbecile!", userResponce);
    break;
    }




    Console.ReadLine();
    //
    // TODO: Add code to start application here
    //
    }
    }
    }
    [QUOTE/]

    please help

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2004
    Posts
    6
    uhm i also need to loop the code so it doesnt close after one responce.. please im really trying to get started so if someone could help ime i would really appreciate it

  4. #4
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    You are not gonna get help like this. You cant just ask for us to do your assignment.

    Anyway, there is a Random number generator in the framework. Search the help files and you should be ok.

    This should be real simple.

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2004
    Posts
    6
    Alright.. thank you and I'm sorry if it came across that way.. I didn't mean for you to do my assignment only to help me find a way to do it myself

  6. #6
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    if the number is less than .5 it's a head and if its greater it's a tail.
    If it's exactly .5 does it land on it's side?

  7. #7

    Thread Starter
    New Member
    Join Date
    Sep 2004
    Posts
    6
    good question

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