Question

Suppose you have already written the class for a Bowler. The Bowler class has two fields,...

Suppose you have already written the class for a Bowler. The Bowler class has two fields, a full name and a high score. Write the main() method to create two instances of this Bowler class. Get the input from the user and send the name and high score values to the constructor method of the Bowler class.

Homework Answers

Answer #1

Hi Buddy, please find the below java program

import java.util.*;

class Bowler{
String fullName;
int highScore;
//Constructor
Bowler(String fullName, int highScore){
this.fullName = fullName;
this.highScore = highScore;
}
//This method returns object as string
@Override
public String toString(){
return fullName+" : "+highScore;
}
}
class Main{
public static void main(String args[]){
//Initializing Scanner
Scanner obj = new Scanner(System.in);
System.out.println("Enter name and score of bowler 1");
//Creating bowler object 1
Bowler b1 = new Bowler(obj.next(),obj.nextInt());
System.out.println("Enter name and score of bowler 2");
//Creating bowler object 2
Bowler b2 = new Bowler(obj.next(),obj.nextInt());
System.out.println("Bowler 1 "+b1);
System.out.println("Bowler 2 "+b2);
}
}

INPUT :

Mcgrath 14
Boult 12

OUTPUT :

Enter name and score of bowler 1
Enter name and score of bowler 2
Bowler 1 Mcgrath : 14
Bowler 2 Boult : 12

Know the answer?
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
Similar Questions
My assignment is listed below. I already have the code complete, but I cannot figure out...
My assignment is listed below. I already have the code complete, but I cannot figure out how to complete this portion: You must create a makefile to compile and build your program. I can't figure out if I need to create a makefile, and if I do, what commands do I use for that? Create a  ContactInfo class that contains the following member variables: name age phoneNumber The ContactInfo class should have a default constructor that sets name = "", phoneNumber...
Classes/ Objects(programming language java ) in software (ATOM) Write a Dice class with three data fields...
Classes/ Objects(programming language java ) in software (ATOM) Write a Dice class with three data fields and appropriate types and permissions diceType numSides sideUp The class should have A 0 argument (default) constructor default values are diceType: d6, numSides: 6, sideUp: randomValue 1 argument constructor for the number of sides default values are diceType: d{numSides}, sideUp: randomValue 2 argument constructor for the number of sides and the diceType appropriate accessors and mutators *theoretical question: can you change the number of...
Write Python code to define a class called Student. The Student class should have the following...
Write Python code to define a class called Student. The Student class should have the following private fields: name – to store the name of a student attend – to store how many times a student attend the class grades – a list of all student’s grades The Student class should have the following methods: a constructor getter method for the name field attendClass method: that increments the attend field (should be called every time a student attends the class)....
Part 1 - LIST Create an unsorted LIST class ( You should already have this code...
Part 1 - LIST Create an unsorted LIST class ( You should already have this code from a prior assignment ). Each list should be able to store 100 names. Part 2 - Create a Class ArrayListClass It will contain an array of 27 "list" classes. Next, create a Class in which is composed a array of 27 list classes. Ignore index 0... Indexes 1...26 correspond to the first letter of a Last name. Again - ignore index 0. index...
Has to be written in C#! Write a program that includes an Employee class that can...
Has to be written in C#! Write a program that includes an Employee class that can be used to calculate and print the take-home pay for a commissioned sales employee. Items to include as data members are employee number, first name, last name, and total sales. All employees receive 9% of the total sales of the month. Federal tax rate is 18%. Retirement contribution is 10%. Social Security tax rate is 6%. Use appropriate constants, design an object-oriented solution, and...
In C++ Employee Class Write a class named Employee (see definition below), create an array of...
In C++ Employee Class Write a class named Employee (see definition below), create an array of Employee objects, and process the array using three functions. In main create an array of 100 Employee objects using the default constructor. The program will repeatedly execute four menu items selected by the user, in main: 1) in a function, store in the array of Employee objects the user-entered data shown below (but program to allow an unknown number of objects to be stored,...
Write a Python class, Flower, that has 3 instance variables name, num_petals and price which have...
Write a Python class, Flower, that has 3 instance variables name, num_petals and price which have types str, int and float. Your class must have a constructor method to initialize the variables to an appropriate value, and methods for setting the value of each instance variable (set methods) and for retrieving the instance variable values (get methods). You can use the credit card code we looked at for assistance.
1. Consider the following interface: interface Duty { public String getDuty(); } a. Write a class...
1. Consider the following interface: interface Duty { public String getDuty(); } a. Write a class called Student which implements Duty. Class Student adds 1 data field, id, and 2 methods, getId and setId, along with a 1-argument constructor. The duty of a Student is to study 40 hours a week. b. Write a class called Professor which implements Duty. Class Professor adds 1 data field, name, and 2 methods, getName and setName, along with a 1-argument constructor. The duty...
(JAVA) Create a class that represents a Customer. Use good OO programming technique. A Customer has...
(JAVA) Create a class that represents a Customer. Use good OO programming technique. A Customer has a firstName, lastName, customerNumber, emailAddress. You can add some more fields if you want to, but those 4 are a minimum. Override the equals method, and the toString method from the Object class. Implement the Comparable interface. In the main method, create some instances of the Customer class, and demonstrate the use of the accessor and mutator methods, as well as the compareTo method.
IN JAVA 1. Write up a small program that accepts two integers from the user. Print...
IN JAVA 1. Write up a small program that accepts two integers from the user. Print which of the two values is bigger. If they are the same, print that they are the same. 2. Write a method that accepts three doubles. Calculate and return the average of the three passed double values. 3. Write up a method that accepts a score between 0-10. Print out a message according to the following table. You ay personally decide the boundaries. i.e.,...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT