//*****DogTripathlonParticipant.java********
//For part(11) codes are commented(you can uncomment accordingly to see output by yourself accordingly) and //output of all the part of part 11 is provided below along with screenshots
public class DogTripathlonParticipant {
// part(1)
private final int NUM_EVENTS;
private static int totalCumulativeScore=0;
//private int totalCumulativeScore=0; //(11)
//(2) declare variables
private String name;
private int obedienceScroe;
private int conformationScore;
private int agilityScore;
private int total;
private double avg;
//Create constructor
public DogTripathlonParticipant(String name,int numEvents,int score1, int score2, int score3)
{
this.name =name;
NUM_EVENTS = numEvents;
obedienceScroe = score1;
conformationScore = score2;
agilityScore = score3;
//(4) calculate total , avg and cumulative score
total = obedienceScroe+conformationScore+agilityScore;
avg =(double)total/NUM_EVENTS;
totalCumulativeScore = totalCumulativeScore+total;
}
//(5) display the result
public void display()
{
//(11)
//NUM_EVENTS = 5;
//Error: The final field DogTripathlonParticipant.NUM_EVENTS cannot be assigned
System.out.println(name+ " participant in "+ NUM_EVENTS+
" events and has an average score of "+avg);
System.out.println(" "+name+ " has a total score of "+total
+" bringing the total cumulative score to "+totalCumulativeScore);
}
}
//****************TestDogs.java file code*****
public class TestDogs {
public static void main(String[] args)
{
//create object dog1 , dog2, dog3
DogTripathlonParticipant dog1= new DogTripathlonParticipant("Bowser", 2, 85, 89, 0);
dog1.display();
DogTripathlonParticipant dog2= new DogTripathlonParticipant("Rush", 3, 78, 72, 80);
dog2.display();
DogTripathlonParticipant dog3= new DogTripathlonParticipant("Ginger", 3, 90, 86, 72);
//DogTripathlonParticipant dog3= new DogTripathlonParticipant("Ginger", 0, 90, 86, 72);
//output: Bowser participant in 0 events and has an average score of Infinity
dog3.display();
//(11)
dog1.display();
}
}
//*********************Output for part before 11****
Bowser participant in 2 events and has an average score of
87.0
Bowser has a total score of 174 bringing the total cumulative score
to 174
Rush participant in 3 events and has an average score of
76.66666666666667
Rush has a total score of 230 bringing the total cumulative score
to 404
Ginger participant in 3 events and has an average score of
82.66666666666667
Ginger has a total score of 248 bringing the total cumulative score
to 652
(11) a)
Bowser participant in 2 events and has an average score of
87.0
Bowser has a total score of 174 bringing the total cumalative score
to 174
Rush participant in 3 events and has an average score of
76.66666666666667
Rush has a total score of 230 bringing the total cumalative score
to 404
Ginger participant in 3 events and has an average score of
82.66666666666667
Ginger has a total score of 248 bringing the total cumalative score
to 652
Bowser participant in 2 events and has an average score of
87.0
Bowser has a total score of 174 bringing the total cumalative score
to 652
b)
//NUM_EVENTS = 5;
//Error: The final field DogTripathlonParticipant.NUM_EVENTS cannot be assigned
c)
Bowser participant in 2 events and has an average score of
87.0
Bowser has a total score of 174 bringing the total cumulative score
to 174
Rush participant in 3 events and has an average score of
76.66666666666667
Rush has a total score of 230 bringing the total cumulative score
to 230
Ginger participant in 3 events and has an average score of
82.66666666666667
Ginger has a total score of 248 bringing the total cumalative score
to 248
d)Bowser participant in 2 events and has an average score of
87.0
Bowser has a total score of 174 bringing the total cumulative score
to 174
Rush participant in 3 events and has an average score of
76.66666666666667
Rush has a total score of 230 bringing the total cumulative score
to 230
Ginger participant in 0 events and has an average score of
Infinity
Ginger has a total score of 248 bringing the total cumulative score
to 248
Bowser participant in 2 events and has an average score of
87.0
Bowser has a total score of 174 bringing the total cumulative score
to 174
//You can see while passing 0 for Ginger its says: Ginger participant in 0 events and has an average score of Infinity
//****Output screenshots****
10) (selected in blue area at bottom of the screen)
11) a) (selected in blue area at bottom of the screen)
//11(b) (you can see error in middle of the screen in the code)
11(c)
11(d) (you can see selected blue area at the bottom of the screen)
//****Please do let me know if you any doubts or want me to modify the code ***
You Do lt Using Static and Nonstatic fina7 Fields In this section, you create a class...
Using your Dog class from earlier this week, complete the following: Create a new class called DogKennel with the following: Instance field(s) - array of Dogs + any others you may want Contructor - default (no parameters) - will make a DogKennel with no dogs in it Methods: public void addDog(Dog d) - which adds a dog to the array public int currentNumDogs() - returns number of dogs currently in kennel public double averageAge() - which returns the average age...
In Java Code Needed is Below the Question Using Program 3: Encapsulating Dogs, modify this program to create a database of dogs of your own. You will also include File I/O with this program. You will create 3 classes for this assignment. The first class: Create a Class representing the information that is associated with one item (one dog) of your database. Name this class Dog. Using Lab 3, this will include the information in regard to one dog. The...
Create a class named Horse that contains the following data fields: name - of type String color - of type String birthYear - of type int Include get and set methods for these fields. Next, create a subclass named RaceHorse, which contains an additional field, races(of type int), that holds the number of races in which the horse has competed and additional methods to get and set the new field. DemoHorses.java public class DemoHorses { public static void main(String args[])...
A. Create a CollegeCourse class. The class contains fields for the course ID (for example, CIS 210), credit hours (for example, 3), and a letter grade (for example, A). Include get and set methods for each field. Create a Student class containing an ID number and an array of five CollegeCourse objects. Create a get and set method for the Student ID number. Also create a get method that returns one of the Student’s CollegeCourses; the method takes an integer...
A. Create a CollegeCourse class. The class contains fields for the course ID (for example, CIS 210), credit hours (for example, 3), and a letter grade (for example, A). Include get and set methods for each field. Create a Student class containing an ID number and an array of five CollegeCourse objects. Create a get and set method for the Student ID number. Also create a get method that returns one of the Student’s CollegeCourses; the method takes an integer...
A. Create a CollegeCourse class. The class contains fields for the course ID (for example, CIS 210), credit hours (for example, 3), and a letter grade (for example, A). Include get and set methods for each field. Create a Student class containing an ID number and an array of five CollegeCourse objects. Create a get and set method for the Student ID number. Also create a get method that returns one of the Student’s CollegeCourses; the method takes an integer...
Create an abstract Student class for Parker University. The class contains fields for student ID number, last name, and annual tuition. Include a constructor that requires parameters for the ID number and name. Include get and set methods for each field; the setTuition() method is abstract. Create three Student subclasses named UndergraduateStudent, GraduateStudent, and StudentAtLarge, each with a unique setTuition() method. Tuition for an UndergraduateStudent is $4,000 per semester, tuition for a GraduateStudent is $6,000 per semester, and tuition for...
Need help with the program DemoSugarSmash.java import java.util.*; public class DemoSugarSmash { public static void main(String[] args) { // Complete the demo program here } } PremiumSugarSmashPlayer.java public class PremiumSugarSmashPlayer { // Define the PremiumSugarSmashPlayer class here } PremiumSugarSmashPlayer.java public class SugarSmashPlayer { private int playerID; private String screenName; private int[] scoresArray ; public SugarSmashPlayer() { this.scoresArray = new int[10]; } public SugarSmashPlayer(int levels) { this.scoresArray = new int[levels]; } public int getIdNumber() { return playerID; } public void setIdNumber(int...
Activity: Writing Classes Page 1 of 10 Terminology attribute / state behavior class method header class header instance variable UML class diagram encapsulation client visibility (or access) modifier accessor method mutator method calling method method declaration method invocation return statement parameters constructor Goals By the end of this activity you should be able to do the following: > Create a class with methods that accept parameters and return a value Understand the constructor and the toString method of a class...
java In this project you will implement a trivia game. It will ask random trivia questions, evaluate their answers and keep score. The project will also have an administrative module that will allow for managing the question bank. Question bank management will include adding new questions, deleting questions and displaying all of the questions, answers and point values. 2. The project can be a GUI or a menu based command line program. 3. Project details 1. Create a class to...