Anyone can do this in C++

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jun 2007
Posts: 18
Reputation: pixrix is an unknown quantity at this point 
Solved Threads: 0
pixrix pixrix is offline Offline
Newbie Poster

Anyone can do this in C++

 
0
  #1
Jun 25th, 2007
Write a program that simulates a lottery. The program should have an array of five integers named lottery, and should generate a random number in the range of 0 through 9 for each element in the array. The user should enter five digits which should be stored in an integer array named user. The program is to compare the corresponding elements in the two arrays and keep a count of the digits that match. For example, the following shows the lottery array and the user array with sample numbers stored in each. There are two matching digits (elements 2 and 4).

lottery array:
5 2 6 9 1

user array:
1 3 6 8 1

The program should display the random numbers stored in the lottery array and the number of digits matching digits. If all of the digits match, display a message proclaiming the user as a grand prize winner.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 539
Reputation: thekashyap will become famous soon enough thekashyap will become famous soon enough 
Solved Threads: 50
thekashyap's Avatar
thekashyap thekashyap is offline Offline
Posting Pro

Re: Anyone can do this in C++

 
0
  #2
Jun 25th, 2007
>> Anyone can do this in C++

Yeah !
Are you Agile.. ?
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 749
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Anyone can do this in C++

 
0
  #3
Jun 25th, 2007
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 18
Reputation: pixrix is an unknown quantity at this point 
Solved Threads: 0
pixrix pixrix is offline Offline
Newbie Poster

Re: Anyone can do this in C++

 
0
  #4
Jun 25th, 2007
Originally Posted by thekashyap View Post
>> Anyone can do this in C++

Yeah !

Can u show me the important part of doing this program. Because I cant figure how to use array 4 this program.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 1,429
Reputation: Nichito is an unknown quantity at this point 
Solved Threads: 30
Featured Poster
Nichito's Avatar
Nichito Nichito is offline Offline
Nearly a Posting Virtuoso

Re: Anyone can do this in C++

 
0
  #5
Jun 25th, 2007
maybe you show us what you have done and we can show you the right way... WE DON'T GIVE HOMEWORK TO THOSE WHO DON'T SHOW ANY EFFORT

we surely can do it... can you?
Last edited by Nichito; Jun 25th, 2007 at 2:49 pm.
-->sometimes i wanna take my toaster in a bath<--
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 263
Reputation: Dukane is an unknown quantity at this point 
Solved Threads: 22
Dukane's Avatar
Dukane Dukane is offline Offline
Posting Whiz in Training

Re: Anyone can do this in C++

 
0
  #6
Jun 25th, 2007
If anyone can do this in C++ then why can't you?

PS: You were wrong, anyone includes me, and I don't know C++ well enough to do this.
It is very important to read this: http://www.catb.org/~esr/faqs/smart-questions.html
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 1,429
Reputation: Nichito is an unknown quantity at this point 
Solved Threads: 30
Featured Poster
Nichito's Avatar
Nichito Nichito is offline Offline
Nearly a Posting Virtuoso

Re: Anyone can do this in C++

 
0
  #7
Jun 25th, 2007
i guess the title is missing a question mark in the end...
-->sometimes i wanna take my toaster in a bath<--
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 539
Reputation: thekashyap will become famous soon enough thekashyap will become famous soon enough 
Solved Threads: 50
thekashyap's Avatar
thekashyap thekashyap is offline Offline
Posting Pro

Re: Anyone can do this in C++

 
0
  #8
Jun 26th, 2007
Originally Posted by Dukane View Post
I don't know C++ well enough to do this.
If you don't know C++ well enough to even give it a try, you should just step back and learn the basics, give this problem a try and come back if you have some issues. Because there is no way someone is gonna teach you C++ language in one post here.
Are you Agile.. ?
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 18
Reputation: pixrix is an unknown quantity at this point 
Solved Threads: 0
pixrix pixrix is offline Offline
Newbie Poster

Re: Anyone can do this in C++

 
0
  #9
Jun 26th, 2007
Originally Posted by thekashyap View Post
If you don't know C++ well enough to even give it a try, you should just step back and learn the basics, give this problem a try and come back if you have some issues. Because there is no way someone is gonna teach you C++ language in one post here.

this is my program..
  1. #include<iostream>
  2.  
  3. using std::cout;
  4. using std::cin;
  5. using std::endl;
  6.  
  7. #include <cstdlib>
  8.  
  9. #include <ctime>
  10.  
  11. int main()
  12. {
  13. int a;
  14. int b;
  15. int c;
  16. int d;
  17. int e;
  18. int A;
  19. int B;
  20. int C;
  21. int D;
  22. int E;
  23.  
  24. cout << "Please Enter 1st Number of Your Prediction" << endl;
  25. cin >> A;
  26.  
  27. while (A < 0)
  28. {
  29. cout << "\nInvalid Number Enter" << "Please Renter 1st Number of Your Prediction\n";
  30. cin >> A;
  31. break;
  32. }
  33.  
  34. cout << "\nPlease Enter 2nd Number of Your Prediction" << endl;
  35. cin >> B;
  36.  
  37. while (B < 0)
  38. {
  39. cout << "\nInvalid Number Enter" << "Please Renter 2nd Number of Your Prediction\n";
  40. cin >> B;
  41. break;
  42. }
  43.  
  44. cout << "\nPlease Enter 3rd Number of Your Prediction" << endl;
  45. cin >> C;
  46.  
  47. while (C < 0)
  48. {
  49. cout << "\nInvalid Number Enter" << "Please Renter 3rd Number of Your Prediction\n";
  50. cin >> C;
  51. break;
  52. }
  53.  
  54. cout << "\nPlease Enter 4th Number of Your Prediction" << endl;
  55. cin >> D;
  56.  
  57. while (D < 0)
  58. {
  59. cout << "\nInvalid Number Enter" << "Please Renter 4th Number of Your Prediction\n";
  60. cin >> D;
  61. break;
  62. }
  63.  
  64. cout << "\nPlease Enter 5th Number of Your Prediction" << endl;
  65. cin >> E;
  66.  
  67. while (E < 0)
  68. {
  69. cout << "\nInvalid Number Enter" << "Please Renter 5nd Number of Your Prediction\n";
  70. cin >> E;
  71. break;
  72. }
  73.  
  74.  
  75. srand ( time(0) );
  76.  
  77. a = ( rand()%10 );
  78. b = ( rand()%10 );
  79. c = ( rand()%10 );
  80. d = ( rand()%10 );
  81. e = ( rand()%10 );
  82.  
  83.  
  84.  
  85. cout << "\nUser Array" << endl;
  86. cout << "---------------------" << endl;
  87. cout << "| " << A << " | " << B << " | " << C << " | " << D << " | " << E << " | " << endl;
  88. cout << "---------------------" << endl;
  89. cout << "\nLottery Array" << endl;
  90. cout << "---------------------" << endl;
  91. cout << "| " << a << " | " << b << " | " << c << " | " << d << " | " << e << " | " << endl;
  92. cout << "---------------------" << endl;
  93.  
  94. {
  95. if (a == A)
  96. cout << "\n1st number is correct" << endl;
  97.  
  98. else (a =! A);
  99. cout << "\n1st number is wrong" << endl;
  100. }
  101.  
  102. {
  103. if (b == B)
  104. cout << "\n2nd number is correct" << endl;
  105.  
  106. else (b =! B);
  107. cout << "\n2nd number is wrong" << endl;
  108. }
  109.  
  110. {
  111. if (c == C)
  112. cout << "\n3rd number is correct" << endl;
  113.  
  114. else (c =! C);
  115. cout << "\n3rd number is wrong" << endl;
  116. }
  117.  
  118. {
  119. if (d == D)
  120. cout << "\n4th number is correct" << endl;
  121.  
  122. else (d =! D);
  123. cout << "\n4th number is wrong" << endl;
  124. }
  125.  
  126. {
  127. if (e == E)
  128. cout << "\n5th number is correct" << endl;
  129.  
  130. else (e =! E);
  131. cout << "\n5th number is wrong" << endl;
  132. }
  133.  
  134. return 0;
  135.  
  136. }
i dont know how to do in array.. btw this is not my homework.. im learning C++ by myself.. i just got this question from a friend.. without answer.. i just need someone to teach me how to use array
Last edited by WaltP; Jun 26th, 2007 at 3:46 am. Reason: Added CODE tags -- you actually typed right over how to use them when you entered this post...
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 33
Reputation: bvgsrs is an unknown quantity at this point 
Solved Threads: 1
bvgsrs bvgsrs is offline Offline
Light Poster

Re: Anyone can do this in C++

 
0
  #10
Jun 26th, 2007
Hey !!! I suggest you to come with an algorithm or psuedocode for your problem and one of us here would let you know where you are wrong or what is missing link in the same.

Do not worry abt the nature of the psuedocode - let it be in simple engish language in stepwise sequence -- but come out with one.

you can then go ahead and put the same in coding.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC