1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Yakvenalex [24]
3 years ago
13

The BaseballPlayer class stores the number of hits and the number of at-bats a player has. You will complete this class by writi

ng the constructor. Write a method called: public BaseballPlayer The constructor should take three parameters to match the three instance variables in the class and then initialize the instance variables with these parameters. The parameters should be ordered so that the name of the baseball player is input first, then their hits, and at bats. In the BaseballTester class, print a call to printBattingAverage to test your constructor. 5.2.5: Batting Average 1 public class Baseballtester 2-{ 3 4- 5 6 7 8 public static void main(String[] args) { BaseballPlayer babeRuth = new BaseballPlayer("Babe Ruth", 2873, 8399); System.out.println(babeRuth); // Call the function printBattingAverage here } 9 10 11 12 0 5.2.5: Batting Average 1 public class Baseballplayer 2-{ private int hits; private int atBats; 5 private String name; // Add constructor here public void printBattingAverage { double battingAverage hits / (double) atBats; System.out.println(battingAverage); } 6 7 8 9 10 - 11 12 13 14 15 16 - 17 18 19 20 21 public String toString() { return name + ": + hits + "/" + atBats; } }
Computers and Technology
1 answer:
atroni [7]3 years ago
7 0

Answer:

class BaseballPlayer {

 private int hits;

 private int atBats;

 private String name;

 public BaseballPlayer(String n,int h,int a) {

   name=n;

   hits=h;

   atBats=a;

 }

 public void printBattingAverage() {

   double battingAverage = hits / (double)atBats;

   System.out.println(battingAverage);

 }

 public String toString() {

   return name + ": "+hits+"/"+atBats;

 }

}

public class Baseballtester{

 public static void main(String[] args){

   BaseballPlayer babeRuth = new BaseballPlayer("Babe Ruth", 2873, 8399);

   System.out.println(babeRuth);

   babeRuth.printBattlingAverage();

 }

}

Explanation:

The BaseballPlayer class is used to get and hold data of an instance of a baseball player. the instance object holds the name, number of hits and bats of the player.

The constructor is used to initialize the name, hits and atBats variables of an instance. The "printBattlingAverage" method returns the ratio of the hits and atBat variable while the string method "toString" returns the name and the hits to atBats ratio in string format.

You might be interested in
Password cracking is a technique used to extract user’s password of application/files without the knowledge of the legitimate us
Vlada [557]

Answer:

Rule based Attack.

Explanation:

                    As password cracking is a technique used to extract user’s password of application/files without the knowledge of the legitimate user. The attacker can use Rule Based Attack to find the password and to intrude or compromise the network and systems.

                    This is like a programming language to generate the password. This involves functions to modify, cut, edit and extend the generally used terms by the user.

5 0
2 years ago
Suppose you can access the caches in the local DNS servers of your department. Can you propose a way to roughly determine the We
lubasha [3.4K]

Answer:

We can periodically take a snapshot of the Domain Name System (DNS) caches in the local  Domain Name System (DNS) servers.

Explanation:

We can periodically take a snapshot of the Domain Name System (DNS) caches in the local  Domain Name System (DNS) servers. The Web server that appears most frequently in the  Domain Name System (DNS) caches is the most popular server. This is because if more users are interested in a Web server, then Domain Name System (DNS) requests for that server are more frequently sent by users. Thus, that Web server will appear in the  Domain Name System (DNS) caches more frequently.  

6 0
3 years ago
The amount of memory used by an array depends upon the array's data type and the number of elements in the array. True False
OverLord2011 [107]

Answer:

True

Explanation:

6 0
2 years ago
Which team behavioral characteristic helps team members to freely express ideas and foster approachability?
vlada-n [284]

Communication is the right answer.

6 0
2 years ago
The option to publish a file as a blog post is located in the____options on the File tab.
shtirl [24]
The answer is #2: Share
3 0
2 years ago
Other questions:
  • Given a scanner reference variable named input that has been associated with an input source consisting of a sequence of integer
    14·2 answers
  • Which of the following is not true about designing classes? In order for class information to be printed instead of a memory add
    12·1 answer
  • A personal identification number (PIN) that opens a certain lock consists of a sequence of 3 different digits from 0 through 9,
    7·1 answer
  • is skill in using productivity software, such as word processors, spreadsheets, database management systems, and presentation so
    10·1 answer
  • Compare userNumber with compareNumber and display 'Numbers are not equal' if the numbers are different. Then, display 'Variables
    11·1 answer
  • Using the Vigenere cipher, does the length of the key matter?
    8·1 answer
  • Best way to build a model bridge
    5·2 answers
  • A _________ is a component commonly used in an analog pressure gauge. Use letter keys to select choices A microprocessor B press
    8·1 answer
  • .Write a MATLAB script that VECTORIZES (eliminates the loop) the following code. (4points)
    14·1 answer
  • Which phrase is the best definition of sparklines in Excel 2016?
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!