C
C#•13mo ago
kiran

please help homework due in 20 mins

Program Description: You are to read an external file of random integer values until the end of file is found. As you read the file you should determine how many numbers are less than the value 500 and how many numbers are greater than or equal to 500. Statements Required: external file input, output, loop control, decision making Data Location: Program 215a.txt Sample Output: The number of numbers less than 500 is 192 The number of numbers greater than or equal to 500 is 208 The total number of numbers is 400 DATA: 123,54,67,38,875,43,88,222,35,677,84,10,32,1,500,7,543,678,94,23,754,32,500,654,861,23,56,77,98,95,4 8,78,64,222,467,871,983,816,278,632,754,8,7,234,654,691,455,987,123,1,45,543,67,23,45,6,982,8,95,743 ,5,982,4,0,29,584,357,94,385,72,394,570,98,5,3,6,9,5,6,500,3,402,1,809,2,43,587,234,888,356,807,2,3,45, 98,777,458,72,357,823,45,723,911 MY CODE: using System; using System.Runtime.CompilerServices; namespace countingnumebrs // Note: actual namespace depends on the project name. { internal class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); string data = ("215a.txt"); string[] num ; StreamReader myreader = new StreamReader(data); string massimo = myreader.ReadLine(); num = massimo.Split(","); int less = 0; int moreequal = 0; int total = 0; for (int i = 0; i < num.Length; i++) { if (Convert.ToInt32(num[i]) < 500) { less++; } else if (Convert.ToInt32(num[i]) <= 500) { moreequal++; } total++; } Console.WriteLine("there are {0} numbers less than 500\nthere are {1} numbers more or equal to 500\nthere are {2} numbers total", less, moreequal, total); } } }
6 Replies
ZacharyPatten
ZacharyPatten•13mo ago
if it is really due in 20 minutes... why would you even bother taking the time to post on discord
kiran
kiranOP•13mo ago
its wroeng help i dont know
ZacharyPatten
ZacharyPatten•13mo ago
we are not going to do your homework for you. You have multiple issues with your code
kiran
kiranOP•13mo ago
ok, why so mad, did your mom kick you out of the basement because your 31 and spend 19 hours on discord? boo hoo 😢
Angius
Angius•13mo ago
Bro really comes here, starts insulting people, and expects OMEGALUL
jcotton42
jcotton42•13mo ago
pro tip: don't come begging for help, only to be a dick to those that could help you good luck, asking your teacher for an extension may be worth it
Want results from more Discord servers?
Add your server