Monday, January 7, 2019
Cis170 Ilab 5
workweek 5 iLab Part A apply remains utilize System. Collections. Generic exploitation System. Linq using System. Text namespace Lab5A class programme atmospherics void Main(string args) string playerName = new string100 int playerScore = new int100 int c = 0 c=InputData( reader playerName, reader playerScore) double avg= Calculate mediocreScore( referee playerScore,c) Console. WriteLine(Name Score) DisplayPlayerData(ref playerName, ref playerScore, c) Console. WriteLine() Console. WriteLine(Average Score + avg + ) Console. WriteLine(Players Who Scored Below Average) Console.WriteLine(Name Score) DisplayBelowAverage(avg, ref playerName, ref playerScore,c) static int InputData(ref string player, ref int score) int addName = 0, take=0 do Console. Write( infix Players Name (Q to quit) ) playercounter = Console. ReadLine() if (playercounter == q playercounter == Q) addName = 1 else Console. Write( project score for 0 , playercounter) scorecounter = Convert. ToInt32(C onsole. ReadLine()) counter++ age (addName = 1) eturn counter static void DisplayPlayerData(ref string playerName, ref int playerScore,int counter) for (int i = 0 i < counter i++) Console. WriteLine(01, playerNamei, playerScorei) static double CalculateAverageScore(ref int playerScore,int counter) int entirety = 0, avg = 0 for (int i = 0 i < counter ++i) total += Convert. ToInt32(playerScorei) if (playerScore. Length > 0) avg = total / counter pass on avg static void DisplayBelowAverage(double avg, ref string playerName, ref int playerScore,int counter) or (int i = 0 i < counter i++) if (playerScorei < avg) Console. WriteLine(01, playerNamei, playerScorei) Console. ReadLine() Part B using System using System. Collections. Generic using System. Linq using System. Text using System. Collections namespace Week_5_iLab_Part_B class course of instruction static void Main(string args) string solution = y ArrayList operateNameAL = new ArrayList() //Con sole. Write(Enter a extreme name ) //LastNameAL. Add(Console. ReadLine()) //Console. Write( happen departure? (Y/N) ) //response = Console.ReadLine() while (response == y) Console. Write(Enter a last name ) LastNameAL. Add(Console. ReadLine()) Console. Write(Keep Going? (y/n) ) response = Console. ReadLine() Console. WriteLine(LastNameAL. Count + last names entered. ) Console. WriteLine(Last names in ascending order. ) LastNameAL. Sort() foreach (string s in LastNameAL) Console. WriteLine(s) Console. WriteLine(Last names in descending order. ) LastNameAL. Reverse() foreach (string s in LastNameAL) Console. WriteLine(s) Console. ReadLine()
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment