Click here to Skip to main content
15,899,025 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
print('''
=======================================
|                                     |
|                                     |
|            Main Menu                |
|                                     |
|                                     |
=======================================
''')
# Lists collecting user input data
win_list = []
lose_list = []
score_list = []
opponent_list = []
# Here is the menu prompting the user to select the desired option to input.
user_input = True
while user_input:
    print('''
    A.) Enter game results
    B.) Current Record
    C.) Display All results from games Won
    D.) Display All results from Opponent
    E.) Quit  
    '''
          )
# Below the code is asking for user input to collect data to be collected by the lists.
    user_input = input('Please select an option from the Menu.').upper()
    if user_input == "A":
        score_input = float(input("Please enter your score"))
        score_list.append(score_input)
        opponent_input = float(input("Please enter the opponents score"))
        opponent_list.append(opponent_input)
        high = max(score_list)
        low = min(score_list)
        result_input = input(''' Please enter the game result.
        A.) Win
        B.) Lose ''').upper()
        if result_input == "A":
            result_input = 1
            win_list.append(result_input)
        elif result_input == "B":
            result_input = 1
            lose_list.append(result_input)
# The lists are being used here for mathematical purposes for the high,low and average data from the users game.
    elif user_input == "B":
        avg_score = sum(score_list) / len(score_list)
        avg_opponent_score = sum(opponent_list) / len(opponent_list)
        print("Highest Game Score Entered:", '%.2f score' % (max(score_list)))
        print("Lowest Game score entered:", '%d score' % (min(score_list)))
        print("Average Game score entered:", '%.2f score' % avg_score)
        print("Highest Opponent Game Score Entered:", '%.2f score' % (max(opponent_list)))
        print("Lowest Opponent Game score entered:", '%d score' % (min(opponent_list)))
        print("Average Opponent Game score entered:", '%.2f score' % avg_opponent_score)
# User's data is displayed for the amount of wins/loses and the scores of those games
    if user_input == "C":
        print("You have Won", sum(win_list), "times and won with this score", score_list)
    elif user_input == "D":
        print("You're Opponent has Won", sum(lose_list), "times and won with this score", opponent_list)
# Input to terminate loop
    elif user_input == "E":
        print("Good Bye")
# If the input does not match the prompted selection this will scream at the user saying they have selected an
# invalid option.
    elif user_input != "":
        print("Input not recognized please try again")


What I have tried:

I have tried writing it from scratch but I don't know how to apply the same logic in C.
Posted
Updated 25-Sep-21 22:14pm

This is not a code conversion service: we are not here to translate code for you.
Even if we did, what you would end up with would not be "good code" in the target language – they are based on very different frameworks, and what makes something work in one language does not always "translate" directly into another.
So what you end up with is very poor code, that is difficult if not impossible to maintain, that can’t be upgraded nicely, and that will cause you immense headaches if the original is changed. And it'll be a nightmare to debug if it doesn’t work "straight out of the box".
Instead, use the source code as a specification for a new app written in and for the target language / framework and write it from scratch using the original as a "template". You will get a much, much better result that will save you a lot of time in the long run.

And to be honest, if you just copy'n'paste someone else's work and hand it in as your own then several things happen:
1) You will fail the course, because you will never learn how to "apply the logic" to C.
2) You will possibly fail the school because teachers are very aware that students try this and look for plagiarism. It's a form of cheating, and can be punished very severely.
3) You have no idea what the code actually does, so it may or may not do what your assignment wanted. Additionally, since you have no idea how it works, you don't know about any side effects - there are those that would find it funny to add ransomware to homework answers to infect your and your teachers machines ...

Sit down, read your homework, and try to answer it yourself. You will learn something from the experience ...
 
Share this answer
 
You need to visit some Learn C tutorial and than recode the solution.

Best is to understand the code and so better use the concepts of C. You will need printf and scanf, so read the documentation about its parameters and usage. For the lists you may use an array of structs.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900