Advertisement
Chiz_Tiu

C# in Visual Studio

Nov 23rd, 2014
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.72 KB | None | 0 0
  1. C# in Visual Studio
  2. C# Program Determining if a number is either a multiple of ten or within a particular set of ranges I have a few loops that I need in my program. I can also write out the c# code but I'm not entirely sure how to write them logically. I need Program that will enter 10 numbers and display the count of number according to ranges. Ranges are 1-10, 11-20, 21-30, 31-40, 41-50, Greater than 50: OUT OF RANGE. [using conditional and looping statement] Just like this example:
  3.  
  4. Ex.
  5. Input 1:    10
  6. Input 2:    15
  7. Input 3: 12
  8. Input 4: 17
  9. Input 5: 20
  10. Input 6: 30
  11. Input 7: 24
  12. Input 8: 6
  13. Input 9: 3
  14. Input 10: 36
  15.  
  16. Output:
  17. Number of counts.
  18. 1-10:   3
  19. 11-20:  4
  20. 21-30:  2
  21. 31-40:  1
  22. 41-50:  0
  23. Out of range: 0
  24. and the second one is Program that will display the following output [using conditional and looping statement] Sequence: A is multiplied to B and added to C.
  25.  
  26. Just like this:
  27.  
  28. A   B   C
  29. 1   2   1
  30. 2   4   3
  31. 3   6   5
  32. 4   8   7
  33. 5   10  9
  34. 6   12  11
  35. 7   14  13
  36. 8   16  15
  37. 9   18  17
  38. 10  20  19
  39.  
  40. Output
  41. 3
  42. 11
  43. 23
  44. 39
  45. 59
  46. 83
  47. 111
  48. 143
  49. 179
  50. 219
  51. This is for a snakes and ladders board game, if it makes any more sense for my question. I imagine the first if statement can write it out like
  52.  
  53. foreach(number in positivenumberArray)
  54.     {
  55.     if (41 > 50)
  56.         Console.Writeline("Out of Range");
  57.     else if(31 > 40)
  58.         Console.Writeline("Range 40-50");
  59.     else if(21 > 30)
  60.         Console.Writeline("Range 30-40");
  61.     else if(11 > 20)
  62.         Console.Writeline("Range 20-30");
  63.     else if(1 > 10)
  64.         Console.Writeline("Range 10-20");
  65.     else
  66.         Console.Writeline("Range 0-10");
  67.     }
  68. but there has to be something smarter than that to be correct?
  69. The second one I have no idea.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement