|
-
Sep 30th, 2004, 07:48 PM
#1
Thread Starter
New Member
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
-
Sep 30th, 2004, 08:08 PM
#2
Thread Starter
New Member
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
-
Sep 30th, 2004, 08:11 PM
#3
Thread Starter
New Member
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
-
Oct 1st, 2004, 01:40 AM
#4
Frenzied Member
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.
-
Oct 14th, 2004, 07:04 PM
#5
Thread Starter
New Member
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
-
Oct 14th, 2004, 08:12 PM
#6
Frenzied Member
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?
-
Oct 14th, 2004, 09:03 PM
#7
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|