Question: Please write this code in C# and include Pseudocode. Make a custom txt file of random colleges and city. import random def main(): print (Welcome
Please write this code in C# and include Pseudocode. Make a custom txt file of random colleges and city.
import random
def main(): print ("Welcome to the College Search App!") print ("----------------------------------------") print() print("Please enter a college and I will return the city. (x to exit, random to get Random College/City)") userinput = input("College: ") while userinput.lower() != "x": with open ("/Users/Random/Desktop/College.txt") as file: collegeDict = {} for line in file: line = line.replace(" ",",") templine = line.split(",") collegeDict.update ({templine[0]:templine[1]}) if userinput == "random": while userinput == "random": collegelist = open("/Users/Random/Desktop/College.txt").readlines() print(random.choice(collegelist)) print("Please enter a college and I will return the city. (x to exit, random to get Random College/City)") userinput = input("College: ") if userinput != "random": break
if userinput in collegeDict: print() print(f"The city of {userinput} is {collegeDict[userinput]}") print("Please enter a college and I will return the city. (x to exit, random to get Random College/City)") userinput = input("College: ") else: print(f"No results were found for {userinput}") print() print("Please enter a college and I will return the city. (x to exit, random to get Random College/City)") print() userinput = input("College: ") print("Goodbye")
if __name__ == "__main__": main()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
