Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- C# in Visual Studio
- 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:
- Ex.
- Input 1: 10
- Input 2: 15
- Input 3: 12
- Input 4: 17
- Input 5: 20
- Input 6: 30
- Input 7: 24
- Input 8: 6
- Input 9: 3
- Input 10: 36
- Output:
- Number of counts.
- 1-10: 3
- 11-20: 4
- 21-30: 2
- 31-40: 1
- 41-50: 0
- Out of range: 0
- 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.
- Just like this:
- A B C
- 1 2 1
- 2 4 3
- 3 6 5
- 4 8 7
- 5 10 9
- 6 12 11
- 7 14 13
- 8 16 15
- 9 18 17
- 10 20 19
- Output
- 3
- 11
- 23
- 39
- 59
- 83
- 111
- 143
- 179
- 219
- 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
- foreach(number in positivenumberArray)
- {
- if (41 > 50)
- Console.Writeline("Out of Range");
- else if(31 > 40)
- Console.Writeline("Range 40-50");
- else if(21 > 30)
- Console.Writeline("Range 30-40");
- else if(11 > 20)
- Console.Writeline("Range 20-30");
- else if(1 > 10)
- Console.Writeline("Range 10-20");
- else
- Console.Writeline("Range 0-10");
- }
- but there has to be something smarter than that to be correct?
- The second one I have no idea.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement