C# adding dynamic variables in loop -
it's pretty rookie question. here code
double jury; jury = double.parse(console.readline()); (int = 0; < jury ; i++) { console.readline(); }
how can define input inside loop can use input data additional inputs math calculations. it's vote system , first variable jury count - each jury member votes number 1-10. idea jury dynamic 1 100,000. ideas welcome.
more: here idea.
-> when have example 3 jury members
-> input 3 on first row
-> 3 new inputs jury vote candidates ( numbers 1 10 )
-> in case votes 1, 3, 3
the idea parse information , output winner in our case "3".
this code prompts number of jurors , validates input. then, prompts each juror's vote, validating vote input.
const int minimumvote = 1; const int maximumvote = 10; int jurorcount; { console.write("enter number of jurors: "); } while (!int32.tryparse(console.readline(), out jurorcount) || jurorcount < 0); var votes = new list<int>(); (int = 0; < jurorcount; i++) { int vote; { console.write("enter juror #{0}'s vote ({1}-{2}): ", + 1, minimumvote, maximumvote); } while (!int32.tryparse(console.readline(), out vote) || vote < minimumvote || vote > maximumvote); votes.add(vote); }
Comments
Post a Comment