Question

write a C# program using replit that uses a loop to input # at bats and # of hits for each of the 9 baseball players on a tea

0 0
Add a comment Improve this question Transcribed image text
Answer #1

C# CODE:

using System;

class MainClass {

public static void Main (string[] args) {

Console.WriteLine ("Enter the Team name:(one time entry)");

string name = Console.ReadLine();

string [,]details=new string[9,3];

int []bats=new int[9];

int []hits=new int[9];

float []avg=new float[9];

float team_avg=0;

for(int i=0;i<9;i++)

{

Console.WriteLine ("Enter the Player name: ");

details[i,0]=name;

details[i,1]=Console.ReadLine();

Console.WriteLine("Enter the Players Position: ");

details[i,2]=Console.ReadLine();

Console.WriteLine("Enter the number of at Bats: ");

string input = Console.ReadLine();

Int32.TryParse(input, out bats[i]);

Console.WriteLine("Enter the number of Hits: ");

input=Console.ReadLine();

Int32.TryParse(input,out hits[i]);

Console.WriteLine("{0}",hits[i]);

avg[i]=(float)hits[i]/(float)bats[i];

Console.WriteLine("{0} batting average is {1}",details[i,1],avg[i].ToString().Substring(1));

team_avg+=avg[i];

}

team_avg/=(float)(9);

Console.WriteLine("The batting average for the {0} is {1}",name,team_avg.ToString().Substring(1));

}

}

Output:

Mono C# compiler version 4.6.2.0 exit status -1 mcs -out:main.exe main.cs mono main.exe Enter the Team name: (one time entry)

After 8 more players are added:

The batting average for the Astros is 727027

Add a comment
Know the answer?
Add Answer to:
write a C# program using replit that uses a loop to input # at bats and # of hits for each of the 9 baseball players on...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a class that encapsulates the concept of a baseball player with the important attributes (name,...

    Write a class that encapsulates the concept of a baseball player with the important attributes (name, position, hits, at bats, batting average). The class will have the following methods: Two constructors (a default and a constructor with all parameters) Accessors, mutators, toString, and equals methods The batting average property will not have a public setter, it will be updated any time the hits and/or at bats is set. The getter will round to three digits (.315 or .276, etc.) All...

  • 1. You will develop a Python program to manage information about baseball players. The program will...

    1. You will develop a Python program to manage information about baseball players. The program will maintain the following information for each player in the data set: player’s name (string) team identifier (string) games played (integer) at bats (integer) runs scored (integer) hits (integer) doubles (integer) triples (integer) homeruns (integer) batting average (real) slugging percentage (real) The first nine items will be taken from a data file; the last two items will be computed by the program. The following formulas...

  • c++ A menu-driven program gives the user the option to find statistics about different baseball players....

    c++ A menu-driven program gives the user the option to find statistics about different baseball players. The program reads from a file and stores the data for ten baseball players, including player’s team, name of player, number of homeruns, batting average, and runs batted in. (You can make up your data, or get it online, for example: http://espn.go.com/mlb/statistics ) Write a program that declares a struct to store the data for a player. Declare an array of 10 components to...

  • Chapter 8 Python Case study Baseball Team Manager For this case study, you’ll use the programming...

    Chapter 8 Python Case study Baseball Team Manager For this case study, you’ll use the programming skills that you learn in Murach’s Python Programming to develop a program that helps a person manage a baseball team. This program stores the data for each player on the team, and it also lets the manager set a starting lineup for each game. After you read chapter 2, you can develop a simple program that calculates the batting average for a player. Then,...

  • Case Study Baseball Team Manager. CMSC 135 Python Chapter 7 Assignment: Use a file to save...

    Case Study Baseball Team Manager. CMSC 135 Python Chapter 7 Assignment: Use a file to save the data Update the program so it reads the player data from a file when the program starts andwrites the player data to a file anytime the data is changed What needs to be updated: Specifications Use a CSV file to store the lineup. Store the functions for writing and reading the file of players in a separate module than the rest of the...

  • Need help writing this code in python. This what I have so far. def display_menu(): print("======================================================================")...

    Need help writing this code in python. This what I have so far. def display_menu(): print("======================================================================") print(" Baseball Team Manager") print("MENU OPTIONS") print("1 - Calculate batting average") print("2 - Exit program") print("=====================================================================")    def convert_bat(): option = int(input("Menu option: ")) while option!=2: if option ==1: print("Calculate batting average...") num_at_bats = int(input("Enter official number of at bats: ")) num_hits = int(input("Enter number of hits: ")) average = num_hits/num_at_bats print("batting average: ", average) elif option !=1 and option !=2: print("Not a valid...

  • Can you please Test and debug the program below using the following specifications? Many thanks! Create...

    Can you please Test and debug the program below using the following specifications? Many thanks! Create a list of valid entries and the correct results for each set of entries. Then, make sure that the results are correct when you test with these entries. Create a list of invalid entries. These should include entries that test the limits of the allowable values. Then, handle the invalid integers (such as negative integers and unreasonably large integers). In addition, make sure the...

  • A competition takes place for the development of a new functionality that will be added on...

    A competition takes place for the development of a new functionality that will be added on the NBA daily stats. This new functionality will show the player with the maximum ratio of points per minute. Develop a program in C++ that prompts the user to enter data for a number of NBA players and then outputs the player(s) with the maximum ratio of points per minute. You can store the players entered by the user in an array of structs...

  • Something is preventing this python code from running properly. Can you please go through it and...

    Something is preventing this python code from running properly. Can you please go through it and improve it so it can work. The specifications are below the code. Thanks list1=[] list2=[] def add_player(): d={} name=input("Enter name of the player:") d["name"]=name position=input ("Enter a position:") if position in Pos: d["position"]=position at_bats=int(input("Enter AB:")) d["at_bats"] = at_bats hits= int(input("Enter H:")) d["hits"] = hits d["AVG"]= hits/at_bats list1.append(d) def display(): if len(list1)==0: print("{:15} {:8} {:8} {:8} {:8}".format("Player", "Pos", "AB", "H", "AVG")) print("ORIGINAL TEAM") for x...

  • In C Program This program will store the roster and rating information for a soccer team. There w...

    In C Program This program will store the roster and rating information for a soccer team. There will be 3 pieces of information about each player: Name: string, 1-100 characters (nickname or first name only, NO SPACES) Jersey Number: integer, 1-99 (these must be unique) Rating: double, 0.0-100.0 You must create a struct called "playData" to hold all the information defined above for a single player. You must use an array of your structs to to store this information. You...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT