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
List some of the cautions related to costume change
Volgvan

Answer:

Costume Change?

Explanation:

You might not have enough time to complete the costume and it may look a little sloppy. Also, if you are in a play, everyone must be notified of the change.

4 0
2 years ago
Add my epic games account "Lil Carr OXB" and if that not work, then "swish4444"
Andrew [12]

Answer:

-_________________________________-

Explanation:

-__________________________________________________________-

3 0
3 years ago
Read 2 more answers
PLEASE CAN ANYBODY ANSWER ANY OF THESE
Pie

16 in Binary is ob10000

32 in Binary ob100000

I'm not sure if those are in 8 bit or not.


6 0
4 years ago
A __________ network is good for connecting computers over boundaries. A)campus area
zmey [24]
I believe the answer is D)system area <span />
8 0
4 years ago
A company pays its salespeople on a commission basis. The salespepople receive $200 per week plus 9% of their gross sales for th
Maurinko [17]

Answer:

using System;

     

public class Program

{

public static void Main()

{

 Console.Write("Enter gross sales: ");

 double sales = Convert.ToDouble(Console.ReadLine());

 double payment = 200 + (sales*0.09);

 Console.Write("total payment for this week is: "+payment);

}

}

Explanation:

May I suppose that you want a program in C# to calculate the week payment? in that case let review a solution:

using System;

     

public class Program

{

public static void Main()

{

//input the gross sales of the week

 Console.Write("Enter gross sales: ");  

//convert the string data to double

 double sales = Convert.ToDouble(Console.ReadLine());

//use described algorithm to calculate the payment

 double payment = 200 + (sales*0.09);

//show the value in console

 Console.Write("total payment for this week is: "+payment);

}

}

6 0
3 years ago
Other questions:
  • A data structure used to bind an authenticated individual to a public key is the definition of ________.
    14·1 answer
  • An authenticated user can add up to how many computer accounts to the domain, by default
    6·1 answer
  • Your website is currently at position 5 in organic search. On a monthly basis you currently get on average 5,432 clicks and 32 c
    7·1 answer
  • Which of these forms of multimedia would most likely contain both music and text:
    14·1 answer
  • What are the functions of online gaming communities?
    12·1 answer
  • What is text box and label control​
    10·2 answers
  • All of the following are examples of being computer literate, EXCEPT ________. Group of answer choices knowing how to build and
    7·1 answer
  • Difrent between computer and computer system​
    9·1 answer
  • Var1 = 1<br> var2 = 2<br> var3 = "3"<br> print(var1 + var2 + var3)
    5·1 answer
  • Tom teaches in a high school. He wishes to sort a spreadsheet containing students' marks in various subjects by descending order
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!