• Log in or sign up for an account here: https://www.sythe.org/login

i need someone to make me a program!

  • Thread starter Thread starter firekill137
  • Start date Start date
F

firekill137

Guest
hi all i need to someone to create a program for me ... i want to be eable to make a list of people and it chose one of them all i ask! coz i wanna make a lotto ingame so i need that :)
 
Dude go look through some C++ Tutorials.
 
An easy prog to make in c. Just make it printf a random # from one to however many lotto tickets there are.
 
I made one in c++. It's probably not the best code...but it works. Here you go:

EDIT: alright, a couple of things:
1.It's annoying to type y or Y after every username, so instead you could change it so it gets out of the first do/while loop if the username is quit999(or something). I could edit that if you arn't very good with c++.
2.Sometimes the random number picked will be zero, I suggest picking a new number when this happens.

tell me what you think

Code:
#include <iostream>
#include <cstdlib>
using namespace std;
 
int main()
{
char anotherNum='y';
char quit='y';
int entries=1; //number of people on list
string userName[100];
 
do
{ 
cout << "Username: ";
cin >> userName[entries];
entries++;
cout << "Would you like to add another? ";
cin >> quit;
}
while ((quit == 'y') || (quit == 'Y'));
do
{
for(int i=1; i < entries; i++)
{
cout << i << ":" << userName[i] << endl;
}
int luckyNum= (rand() % entries);
cout << "There are " << entries-1 << " entries on the list." << endl;
cout << "The lucky number was " << luckyNum << endl;
cout << userName[luckyNum] << " is the winner!" << endl;
cout << "Would you like to pick another number? ";
cin >> anotherNum;
}
while ((anotherNum == 'y') || (anotherNum =='Y'));
 
return 0;
}
 
Runescape Gamblingrunescape gambling
Back
Top