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
What kind of attack allows for the construction of LDAP statements based on user input statements, which can then be used to acc
abruzzese [7]

Answer:   b. LDAP injection

Explanation:

LDAP (Lightweight Directory Access Protocol ) Injection is defined as

  • an injection attack used by attacker to exploit web based applications by inserting LDAP statements based on user input.
  • It may be possible modify LDAP statements through some techniques if an application fails to properly sanitize user input.

So,<u> LDAP injection</u> is the attack that allows for the construction of LDAP statements based on user input statements, which can then be used to access the LDAP database or modify the database's information.

Hence, the correct option is b. LDAP injection.

4 0
3 years ago
Finish the program by choosing the correct terms.
juin [17]
What are the exact numbers
6 0
3 years ago
Read 2 more answers
Drag the tiles to the correct boxes to complete the pairs.
Gala2k [10]

Answer:

So the first one i think is A. The second is 2, and that i do know

Explanation:

6 0
3 years ago
In what year did the manager and team depicted in the blockbuster film "Moneyball
mariarad [96]
2006 is the answer and the boston red sox were the first team to win 5 chamships 
3 0
3 years ago
What is computer science​
adell [148]

Answer:

computer science is the study of computer and computing as well as theoretical and practical applications.

pls give me thanks ☺️☺️

7 0
3 years ago
Other questions:
  • Software that was designed to serve the needs of a specific company or organization is called:
    5·1 answer
  • Mateo could not find the undo command or shortcut. He should _____.
    15·2 answers
  • To what would you compare the transport layer?
    14·1 answer
  • A company purchased a high-quality color laser printer to print color brochures and sales proposals. The printer is connected to
    5·1 answer
  • An online journal or diary you create to share your thoughts, opinions and personal news is referred to
    13·1 answer
  • 4. UPS stands for Uninterrupted Power Supply . (Yes /no
    11·1 answer
  • Assume you are using the text's array-based queue and have just instantiated a queue of capacity 10. You enqueue 5 elements and
    13·1 answer
  • State any three reasons why users attach speakers to your computer​
    15·2 answers
  • Help pweeze this is due today :(<br><br> I will give u brainliest just pweeze, I need this answer :(
    8·1 answer
  • HELPPPP MEEEE!!!!! ITS LIFE OR MUERTEEE
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!