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 does PR stand for ?
ss7ja [257]

Answer:

Public Relations or Pull Request (computer programming)

Explanation:

Hope this helps

3 0
2 years ago
How many cost units are spent in the entire process of performing 40 consecutive append operations on an empty array which start
Alexus [3.1K]

Answer:

Explanation:

260 cost units, Big O(n) complexity for a push

6 0
2 years ago
The ___ appears at the bottom of the windows desktop; it is used to launch and manage programs.
asambeis [7]
<span>The taskbar appears at the bottom of the windows desktop. It is used to launch and manage programs. 
</span>The taskbar is part of the GUI (Graphical User Interface) . The most common uses of the taskbar is to<span> to locate and launch programs through the Start button, to view any program that is currently open, check the date an time.</span>
4 0
2 years ago
To copy the formatting of selected text to another place in the document use _____.
ANEK [815]
To copy the formatting of selected text to another place in the document use the paintbrush AKA. Format painter
7 0
3 years ago
The network team has well established procedures to follow for creating new rules on the firewall. This includes having approval
jarptica [38.1K]

Answer:

hello your question has missing options below are the missing options

A. Monitor all traffic using the firewall rule until a manager car) approve it.

B. Immediately roll back the firewall rule until a manager can approve it

C. Don't roll back the firewall rule as the business may be relying upon it, but try to get manager approval as soon as possible.

D. Have the network team document the reason why the rule was implemented without prior manager approval.

answer : Don't roll back the firewall rule as the business may be relying upon it, but try to get manager approval as soon as possible. ( C )

Explanation:

A good step to have in the procedures of a situation like this is

Don't roll back the firewall rule as the business may be relying upon it, but try to get manager approval as soon as possible.

4 0
3 years ago
Other questions:
  • How to you put a color into a cell? <br> a.Shading<br><br> b.Fill<br><br> c.Color<br><br> d.Insert
    8·1 answer
  • Design and implement a class Country that stores the name of the country, its population, its area, and the population density (
    6·1 answer
  • Which of the following statements is false?
    12·1 answer
  • The main characteristic of ____ is that its source code is published with the software.
    7·1 answer
  • . A register in a computer has a of bits. How many unique combinations can be stored in the register?
    5·1 answer
  • zeroIt is a function that takes one argument and returns no value. The function stores the value 0 back into the parameter. x is
    8·1 answer
  • Consider the most important item among all the categories of information stored on your personal computer. As it applies to that
    8·1 answer
  • HELP 11 pointsw to the person who helps me
    11·2 answers
  • Select three physical forms of storage. USB drive Primary cache Magnetic storage Secondary cache Dynamic RAM Optical drive
    7·2 answers
  • DERECTIONS: Identify all the computer software that you need for the following entrepreneurial activities. Refer your answer fro
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!