Write a program which allows a League of Legends player to both store and output statistics on their games played. When the program starts it allows the user to enter new entries. The entries contain the following information: Champion Name Kills Assists Deaths Win? Each entry is appended to a file called games.txt. When the user is done entering data the statistics from the games in the file are to be displayed. The average kills, assists, and deaths are to be displayed with the percentage of wins to be displayed.
Here is the solution of the above problem in java. Save the file with name Main.java and run javac Main.java . To get output run java Main. import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.Scanner; class Player { //Champion Name Kills Assists Deaths Win String championName; Integer kills; Integer assists; Integer deaths; Integer wins; Player(String championName, Integer kills, Integer assists, Integer deaths, Integer wins) { this.championName = championName; this.kills = kills; this.assists = assists; this.deaths = deaths; this.wins = wins; } } class Application { private ArrayList<Player> players; private Scanner sc; private BufferedWriter out; // file name private final String FILE_NAME = "games.txt"; Application() throws IOException { players = new ArrayList<>(); // initialize players list sc = new Scanner(System.in); // for taking system input out = new BufferedWriter(new FileWriter(FILE_NAME, true));// initialization bufferedWriter } // Enter details of players void enterPlayerData() throws IOException { //Champion Name Kills Assists Deaths Win String choice; // for storing choice (yes/no) do { // run until choice is other than yes System.out.println("Enter Champion Name?"); String name = sc.next(); System.out.println("Enter number of kills?"); Integer kills = sc.nextInt(); System.out.println("Enter number of assists?"); Integer assists = sc.nextInt(); System.out.println("Enter number of deaths?"); Integer deaths = sc.nextInt(); System.out.println("Enter number of wins?"); Integer win = sc.nextInt(); //create instance of player and store it into player list players.add(new Player(name, kills, assists, deaths, win)); String str = name + "\t" + kills + "\t" + assists + "\t" + deaths + "\t" + win + "\n"; out.write(str); System.out.println("Do you want to enter more(yes/no)?"); choice = sc.next(); } while (choice.equalsIgnoreCase("yes")); // close file out.close(); // for printing statics of entered data... it does not consisting old data which file already have System.out.println("\n\nPrinting statics of players...."); printStatics(); } private void printStatics() { Integer totalKills = 0; Integer totalAssists = 0; Integer totalDeaths = 0; Integer totalWins = 0; // loop through players and store that into appropriate variables for (Player p : players) { totalAssists += p.assists; totalKills += p.kills; totalDeaths += p.deaths; totalWins += p.wins; } // change formula according to your need ... here i'm doing is // calculating total and dividing with total number of players... you can change according to your need // average kills = (total number of kills / total players) System.out.println("Average kills: " + Float.valueOf(totalKills)/players.size()); // average assists = (total number of assists / total players) System.out.println("Average Assists: "+ Float.valueOf(totalAssists)/players.size()); // average deaths = (total number of deaths / total players) System.out.println("Average Deaths: "+ Float.valueOf(totalDeaths)/players.size()); // percentage wins = (total number of win / (total number of wins + total number of deaths)) System.out.println("Percentage of wins: "+ (Float.valueOf(totalWins)/(totalWins + totalDeaths))*100); } } // Driver class public class Main { public static void main(String[] args) throws IOException { // create instance of Application Application app = new Application(); app.enterPlayerData(); // call function enterPlayerData() } }
//Output
Write a program which allows a League of Legends player to both store and output statistics...
PLEASE INCLUDE SAW-PROMPTS FOR 2 PLAYERS NAMES(VALIDATE NAMES). SHOW MENU (PLAYER MUST SELECT FROM MENU B4 THE GAME STARTS 1=PLAY GAME, 2=SHOW GAME RULES, 3=SHOW PLAYER STATISTICS, AND 4=EXIT GAME WITH A GOODBYE MESSAGE.) PLAYERS NEED OPTION TO SHOW STATS(IN A DIFFERNT WINDOW-FOR OPTION 3)-GAME SHOULD BE rock, paper, scissor and SAW!! PLEASE USE A JAVA GRAPHICAL USER INTERFACE. MUST HAVE ROCK, PAPER, SCISSORS, AND SAW PLEASE This project requires students to create a design for a “Rock, Paper, Scissors,...
I need to create a Tic Tac Toe program in C++. These are the requirements Write a program that allows the computer to play TicTacToe against a human player or allow two human players to play one another. Implement the following conditions: The player that wins the current game goes first in the next round, and their symbol is X. The other player will be O. Keep track of the number of games played, wins, and draws for each player....
Write a C++ console application that allows your user to capture rainfall statistics. Your program should contain an array of 12 doubles for the rainfall values as well as a parallel array containing the names of the months. Using each of the month names, prompt your user for the total rainfall for that month. The program should validate user input by guarding against rainfall values that are less than zero. After all 12 entries have been made, the program should...
Write a Java program that displays the following menu to the user (and allows the user to make a valid selection): 1- Tournament Selection 2- Magic Squares 3 -Arrival Time 4- Quit Once a valid selection is made, your program will run the appropriate code for each program. The description for each program is as follows: In a tournament, each player plays six games and then they are 1 - Tournament Selection: placed in a specific group based on their...
Please write the program in python: 3. Design and implement a simulation of the game of volleyball. Normal volleyball is played like racquetball, in that a team can only score points when it is serving. Games are played to 15, but must be won by at least two points. 7. Craps is a dice game played at many casinos. A player rolls a pair of normal six-sided dice. If the initial roll is 2, 3, or 12, the player loses....
Write a Python program (rock_paper_scissors.py) that allows two players play the game rock paper scissors. Remember the rules: 1. Rock beats scissors 2. Scissors beats paper 3. Paper beats rock The program should ask the users for their names, then ask them for their picks (rock, paper or scissors). After that, the program should print the winner's name. Note, the players may pick the same thing, in this case the program should say it's tie. when the user input an...
Topics: list, file input/output (Python) You will write a program that allows the user to read grade data from a text file, view computed statistical values based on the data, and to save the computed statistics to a text file. You will use a list to store the data read in, and for computing the statistics. You must use functions. The data: The user has the option to load a data file. The data consists of integer values representing student...
Python Programming Topics: list, file input/output You will write a program that allows the user to read grade data from a text file, view computed statistical values based on the data, and to save the computed statistics to a text file. You will use a list to store the data read in, and for computing the statistics. You must use functions. The data: The user has the option to load a data file. The data consists of integer values representing...
(C++) Write a program that declares a struct to store the data of a football player (player’s name, player’s position, number of touchdowns, number of catches, number of passing yards, number of receiving yards, and the number of rushing yards). Declare an array of 10 components to store the data of 10 football players. Your program must contain a function to input data and a function to output data. Add functions to search the array to find the index of...
Java CSC252 Programming II Static Methods, Enums, Constants, Random Rock Paper Scissors Write a program that allows the user to play "Rock, Paper, Scissors". Write the RPS class. All code should be in one file. main() will be part of the RPS class, fairly small, and contain only a loop that asks the user if they want to play "Rock, Paper, Scissors". If they say yes, it calls the static method play() of the RPS class. If not, the program...