C
C#3y ago
daniel1

tough homework 3

Roy and Tal are playing basketball. During the season there are 10 games. Write a program that captures the number of points scored by each of them in each of the 10 games and displays as output: A. For each of the games the player who scored more points. B. the total points of both players together.
25 Replies
daniel1
daniel1OP3y ago
" class Program { static void Main(string[] args) { int tal, roi; for (int i = 1; i <= 10; i++) { Console.WriteLine("enter tals throws"); tal = int.Parse(Console.ReadLine()); Console.WriteLine("enter rois throws"); roi = int.Parse(Console.ReadLine()); } } } }" this is what i have come up with so far i am just not so sure about how i am supposed to procced with A
Pobiega
Pobiega3y ago
do you know how to compare numbers?
daniel1
daniel1OP3y ago
define "compare" static void Main(string[] args) { int tal, roi,roisum=0,talsum=0, sum=0; for (int i = 1; i <= 10; i++) { Console.WriteLine("enter tals throws"); tal = int.Parse(Console.ReadLine()); talsum = talsum + tal; Console.WriteLine("enter rois throws"); roi = int.Parse(Console.ReadLine()); roisum = roisum + roi; sum = roisum + talsum; } Console.WriteLine("total throws=" + sum); } } } i think that covers B but i still dont understand how to do A
Pobiega
Pobiega3y ago
as in, compare two numbers and tell which one is higher
daniel1
daniel1OP3y ago
yeah but its in for
Pobiega
Pobiega3y ago
so?
daniel1
daniel1OP3y ago
so how exactely am i supposed to do it like what am i supposed to write
Pobiega
Pobiega3y ago
if(tal > roi) seems like a good start.
daniel1
daniel1OP3y ago
ok class Program { static void Main(string[] args) { int tal, roi,roisum=0,talsum=0, sum=0; for (int i = 1; i <= 10; i++) { Console.WriteLine("enter tals throws"); tal = int.Parse(Console.ReadLine()); talsum = talsum + tal; Console.WriteLine("enter rois throws"); roi = int.Parse(Console.ReadLine()); roisum = roisum + roi; sum = roisum + talsum; if (tal > roi) { Console.WriteLine("tal scored more"); } else { Console.WriteLine("roi scored more"); } } Console.WriteLine("total throws=" + sum); } } } is this good ?
Pobiega
Pobiega3y ago
Seems to do the trick.
daniel1
daniel1OP3y ago
this is supposed to be submited on paper and it will be graded
Pobiega
Pobiega3y ago
I wonder if perhaps you are supposed to take input BEFORE doing any output instead of doing output gradually have you covered arrays at all up to this point?
daniel1
daniel1OP3y ago
do you want me to put "if" outside of "for"
Pobiega
Pobiega3y ago
I'd prefer if you answered my question. Moving the if currently would only let you compare the result of a single round, not all 10
daniel1
daniel1OP3y ago
whats arrays
Pobiega
Pobiega3y ago
then you likely have not.
daniel1
daniel1OP3y ago
in the qustion i am asked about everysingle game sepreatly in a and in B its about total so i put it out outside
Pobiega
Pobiega3y ago
can definately interpret A to be that it expects a "table" of sorts, but if you have not covered arrays yet then its a safe bet you dont need to do that
daniel1
daniel1OP3y ago
how would arrays look like maybe i covered it and i just dont know what its called in english
Pobiega
Pobiega3y ago
int[] myIntArray;
daniel1
daniel1OP3y ago
does it function difrently then a reglur int
Pobiega
Pobiega3y ago
yes, it stores more than one
daniel1
daniel1OP3y ago
any intger can store more then one
Pobiega
Pobiega3y ago
not an int more than one. I mean more than one int
daniel1
daniel1OP3y ago
but dont i alrady have for for this oh yeah that very complacited and i defenitly did not do arrey yet
Want results from more Discord servers?
Add your server