public class HeartRateMonitor private int currentHeartRate: private int targetHeartRate private String ownerName, ) Write a mutator (setter) for targetHeartRate. Only allow a value between 0-200 (inclusive), otherwise print out a warning ("Illegal target heart rate") and leave targetHeartRate unchanged.
Q: public class SharedCounter {int counter = 0;public static void main(String [] args) throws…
A: Threads in java: A thread in java, is the independent path of the execution in a program. Many…
Q: public class Prisoner { private static int prisonerCount = 0; private int queueNo; public static…
A: Given: public class Prisoner{ private static int prisonerCount=0; private int queueno;…
Q: public class DebugBox
A: Approach Here, DebugBox class is created to calculate the volume of a box N the class, the…
Q: public class StudentsLI extends Students{ public String svName; public String companyName; public…
A: I created a override grading method as per your requirement and also gives the code along with…
Q: class Moo{ public: int m; Moo (int v=-1){m=v;} }; class Foo { private: int x; protected: int y;…
A: Given The answer is given below output: 10 -1 4 6 ok 10 -1 6 12 ok 9 8
Q: In this class all the methods have public modifiers. Instructor -int ID -String name -String status…
A: SOLUTION: TRUE The class is basically the blueprint using which the objects are created. The method…
Q: The LocalDate class includes an instance method named lengthOfMonth() that returns the number of…
A: A required program is as follows, File name: "DaysTilNextMonth.java" //Import a class LocalDate from…
Q: In this example ,GradeBook class has one attribute and some methods to access this attribute data:…
A: We need to make a static function output in GradeBookTest. Its parameter will object of GradeBook.…
Q: Consider the following class, write a set method for the email attribute that excepts only the new…
A: Sample Response: // Java Programimport java.util.*;//Account calss declareclass Account{ private…
Q: Class Student A Student object represents a student. A student has a first name, middle name and…
A: you have to define both the method in the Class and then take input and return the output as a full…
Q: iven a Card class, implement a subclass called IDCard class. public class Card
A: public class Card { private String name; public Card(String n) { this.name = n; }…
Q: class MidtermExam{ private int hour; private String exam; private boolean isResit; public…
A: Programs are the set of lines of code that is used to provide instructions to the computer. The…
Q: iii. Consider the following two classes: Author and Editor. class Author } public String Name;…
A: In this Question we have to consider two classes which are tightly coupled classes and we have to…
Q: The BankAccount class models changes to the balance of a person's savings account. public class…
A: Below are the answers for given questions:
Q: Java) Q2 Explain the answer step-by-step and include verbal explanation. Thank you! Given…
A: The deep copy of an object is done such that when changing the data members in the original object,…
Q: Write a compareTo () method for this Student class. public class Student { private String name;…
A: compareTo(): method is used to compare to objects inputs to this method is: the object that you have…
Q: Given the following code, what will the output be? Will the code compile and execute? If so, what…
A: Hi. Let's move on to the solution in the next step.
Q: Find output: public class Clrce ( private int raduls: private int first3; private static int M-0;…
A: In step 2, you can see the editable java code. In step 3, you can see the output.
Q: Make this code Runable Kid.java public class Kid { private static int idStatic=0; private int…
A: Add Main.java file Add Main class and write code in main method Create instances of classes and…
Q: Make a class 'StringMethods! It contains a private instance String variable. Add these instance…
A:
Q: Modify the FrultBasket class as follows: - Fruit baskets should have one attribute basket: an array…
A: public class Fruit { //attributes protected String name = null; protected String colour = null;…
Q: The VideoTapeclass holds information about a single television programme recorded on a video tape…
A: Java code: class VideoTape { // the title of the programme private String title; // classification…
Q: } public class TestCircleWithCustomException { public static void main(String[] args) { try ( ( new…
A: Highlighted words are the answer for the empty blocks in this code to complete this exception…
Q: For the following class, write the code to create two different objects: public class Course{…
A: To create objects simply write , className objectName=new className(parameters); //constructor…
Q: Find output: public class Circle( private int raduis; private int first; private static int M-0;…
A: In step 2, you will get the answer.
Q: //PLEASE CORRECT MY MISTAKES, THANK YOU public class Person { private String personID; private…
A: As per the question, solution is mentioned below:
Q: Create a class called "Session12Lab". Create a method public static String[] mergeArrays(String[]…
A: Please find the answer below :
Q: Make a class 'StringMethods'. It contains a private instance String variable. Add these instance…
A: public class StringMethods { private String line; public StringMethods(String line) {…
Q: How do I fix the code? import java.util.*; import java.util.Arrays; public class Movie {…
A: //import java.util.Arrays;public class Movie {private String movieName;private int…
Q: class Player { protected: string name; double weight; double height; public:…
A: Note: since your question contain multiple subparts but we can answer only 3sub-parts at a time…
Q: Make a class 'StringMethods' It contains a private instance String variable. Add these instance…
A: Here are the 3 classes in JAVA ===============================================================…
Q: Which import statement should be included in the source code of a class so that the String class is…
A: h: import java.lang.*;
Q: Insert XXX to output the student's ID. public class Student { private double myGPA; private int…
A: Option 3 is the correct answer: System.out.println("Student ID: "+s.getID());
Q: class entException extends ExcCeption{ int id; public StudentException (int id){this.id = id;}…
A: Solution
Q: class Student { private String stdname; private String stdid; private String stddept; public…
A: public class Student{ private String stdName; private int stdAge; private String stdAddress; private…
Q: public class VisitorPackage { // Declare data fields: an int named travelerID, // a String named…
A: Create a class named VisitorPackage, it has the following member: An integer type data field named…
Q: Write a second constructor as indicated. Sample output: User1: Minutes: 0, Messages: 0 User2:…
A: Program //PhonePlan.java public class PhonePlan { private int freeMinutes; private int…
Q: Public classTestMain { public static void main(String [ ] args) { Car myCar1,…
A: Solution: Given,
Q: public class private String studentName: private int studentAge: public this.studentName - "No name…
A: In this code we have to fill all the blank space with the correct name of the class and method…
Q: / * * * The VideoTapeclass holds information about a single television programme recorded on a video…
A: The class is a user-defined data type in which it wraps data members and member functions. The class…
Q: public class Timel extends Object { private int hour; private int minute; private int second; public…
A: -> It is a library for formating into DecimalFormat. -> It is a constructor of class Time1…
Q: Beginning tests. UNIT TEST FAILED: addInventory() Tests complete. Note: UNIT TEST FAILED is preceded…
A: File name: “CallInventoryTag.java” import java.util.Scanner; public class CallInventoryTag {…
Q: Add a firstname parameter of type String to myMethod, and output "Azeneth Garcia". static void…
A: - We need to complete the java code provided for the name string output. - For executing the code,…
Q: This class includes a constructor that begins on line 8; however, it contains an error. Describe the…
A: The following code :public class Author2 {3 private String name;4 private int numberOfAwards;5…
Q: 2. Every circle has a center and a radius. - Given the radius, we can determine the circle's area…
A: Here I written Java code as per given problem below. I hope you like it.
Q: 2. TestScores Class Custom Exception Write an exception class named InvalidTestScore. Modify the…
A: Java is a programming language originally developed by James Gosling at Sun Microsystems (which is…
Q: public class A { private int var1; public int f1() {...} public int f1(int n1) {...} public int…
A: public class A{private int var1;public int f1() {...}public int f1(int n1) {...}public int f2(int…
Q: Assign isTeenager with true if kidAge is 13 to 19 inclusive. Otherwise, assign isTeenager with…
A: // Import the required packageimport java.util.Scanner; public class TeenagerDetector{ public static…
Q: public class circleDemo public dass Circle{ private int raduis; private int first; private static…
A: Circle one = new Circle(); It will create an object of class Circle and also initialize the…
Step by step
Solved in 2 steps
- public class VisitorPackage{// Declare data fields: an int named travelerID, // a String named destination, and // a double named totalCost.// Your code here... // Implement the default contructor.// Set the value of destination to N/A, and choose an // appropriate value for the other data fields,// Your code here... // Implement the overloaded constructor that passes new// values to all data fields.// Your code here... // Implement method getTotalCost to return the totalCost.// Your code here... // Implement method applyDiscount.//// This method applies a discount off of the total cost// of the tour. The way the discount is applied depends// on the kind of visitor.//// Child discount: the unit discount is subtracted ONCE// from the total cost of the tour.// Senior discount: the unit discount is subtracted TWICE// from the total cost of the tour.// Parameters:// - a char to indicate the kind of visitor// ('c' for child, 's' for senior)// - a double that indicates the amount of the…public class StringArrayManipulation { public static double getSum(String[][] data) { ????? // code goes here } public static void main (String[] args) { String [][] data = { {"Abc,1abc2,12.3,23 west,7.88"}, {"sdf,1agdfgdfgdfgbc,2342.3,23 east,34.34"}, {"Abrgdfhc,1adfbc2,132.3,22 west,34.2"}, {"Abthhc,1adffdggbc2,142.3,21 west,23.5"}, {"ryreyh,1arttt4t43bc2,1232.3,233 west,325.55"}, {"Abbbgfbfgbc,1abrgfhfbc2,152.3,53 west,45.34"}, {"A5yyeybc,1a454tbc2,89.7,26 west,325.6"}, {"Ah5yybc,1afg3bc2,28.9,28 west,234.2"} }; System.out.println("Expected output: 4132.4, output: " + getSum(data)); } }We have a main class that implements a parking charge class of a parking management system. We wanted to generate a junit test class for our main class. Generate a junit test class for our main class ParkingCharge class class Instant{public int hours;public int minutes;} public class ParkingCharge{public String permitID;public String lotID;public double amount;public Instant incurredTime = new Instant(); // toString class definition@Overridepublic String toString(){String permitDetails = "\nPermit ID: "+permitID;String lotDetails = "\nLot ID: "+lotID;String incurredDetails="\nDuration: "+incurredTime.hours+" HH "+incurredTime.minutes+" MM"; // lets say 1 minutes of parking charge is 1 dollaramount = incurredTime.hours*60 + incurredTime.minutes; String amountDetails = "\nParking Charge: "+amount; return permitDetails+lotDetails+incurredDetails+amountDetails;}} Main Class import java.util.Scanner;public class main {public static void main(String [] args){Scanner sc = new…
- I need help write this java code, described in the image below public class Person { private int ageYears; private String lastName; public void setName(String userName) { lastName = userName; } public void setAge(int numYears) { ageYears = numYears; } // Other parts omitted public void printAll() { System.out.print("Name: " + lastName); System.out.print(", Age: " + ageYears); }}// ===== end ===== // ===== Code from file Student.java =====public class Student extends Person { private int idNum; public void setID(int studentId) { idNum = studentId; } public int getID() { return idNum; }}// ===== end ===== // ===== Code from file StudentDerivationFromPerson.java =====public class StudentDerivationFromPerson { public static void main(String[] args) { Student courseStudent = new Student(); /* Your solution goes here */ }}// ===== end =====Implement your own indexOf(String s) and lastIndexOf(String s) methods without using the built-in ones available in Java String class. Complete the following program://course: CSC190//project: Lab 12//date: (today’s date)//author: (your name)//purpose:import java.util.Scanner;class MyString {String s; //default constructor which sets s to a null string //your code here //additional constructor which sets s to the string passed from the caller //your code here //get and set methods for s //your code here //return the index within s of the first occurrence of str. //return -1 when str is not found on s. //if s = "aabababb", s = "aba", return 1 //if s = "aabababb", s = "abaa", return -1 int indexOf(String str) { //your code here} //return the index within s of the last occurrence of str. //return -1 when s is not found on str. //if s = "aabababb", s = "aba", return 3 //if s = "aabababb", s = "abaa", return -1 int lastIndexOf(String s) { //your…This is the Exam class mentioned public class Exam { private int day; private int month; private int year; private int hour; private int minutes; private double maxMarks; private final String type; private final int order; private static int labExamCounter = 0; private static int midtermExamCounter = 0; public static final String LAB_EXAM = "Lab Exam"; public static final String MIDTERM_EXAM = "Midterm Exam"; public static final String FINAL_EXAM = "Final Exam"; public Exam(String type) { this (type, 0, 0, 0, 0, 0, 0); } public Exam(String type, double maxMarks) { this (type, maxMarks, 0, 0, 0, 0, 0); } public Exam(String type, double maxMarks, int day, int month, int year) { this (type, maxMarks, day, month, year, 0, 0); } public Exam(Exam other) { this (other.getType(), other.getMaxMarks(), other.getDay(), other.getMonth(), other.getYear(), other.getHour(),…
- public class DebugBox { privateint width; privateint length; privateint height; publicDebugBox() { length = 1; width = 1; height = 1; } publicDebugBox(intwidth,intlength,intheight) { width = width; length = length; height = height; } publicvoidshowData() { System.out.println("Width: " + width + "Length: " + length + "Height: "+ height); } publicdoublegetVolume() { double vol = length * width * height; return vol; } } // This class uses a DebugBox class to instantiate two Box objects public class DebugFour3 { publicstaticvoidmain(Stringargs[]) { int width =12, length = 10, height = 8; DebugBox box1 =newDebugBox(); DebugBox box2 =newDebugBox(width, length, height); System.out.println("The dimensions of the first box are"); box1.showData(); System.out.print("The volume of the first box is "); showVolume(box1); System.out.println("The dimensions of the second box are"); box2.showData(); System.out.print("The volume of the second box is "); showVolume(box2); }…Java. Create a new class FruitBasket that will store fruit objects in a basket. Starter code. import java.util.*; public class Fruit{//attributesprotected String name = null;protected String colour = null; //constructorpublic Fruit(String name, String colour){this.name = name;this.colour = colour;} //Getterspublic String getName(){return name;}public String getColour(){return colour;}//Setterspublic void setName(String name){this.name = name;}public void setColour(String colour){this.colour = colour;} public String toString(){String fruitDetails = name+" ("+colour+")";return fruitDetails;}} import java.util.*; public class FruitBasket{ public String toString(){String basketContents = "FRUIT BASKET:\n";for (Fruit fruit: basket) {basketContents += fruit.toString()+"\n";}return basketContents;}} import java.util.*; public class PoD { public static void main( String [] args ) {Scanner in = new Scanner( System.in );FruitBasket fruitBasket = new FruitBasket();…******* In java ***** create a class , and objects for the following exercise 1- for car car - make -yearModel + setMake() + setYearModel() + getMake() + getYearModel() 2- for cellphone cellPhone - manufact : String - model : String - retailPrice : double + setManufact(man : String) : void + setModel(mod : String) : void + setRetailPrice( price : double) : viod + getManufact() : String + getModel() : String + getRetailPrice() : double
- Please draw the UMLfor this code package lap; import java.util.Date; class Covenant { private String name; private String type; private Date dateCreated; private String employeeName; private int employeeID; public Covenant(String name, String type, Date dateCreated, String employeeName, int employeeID) { this.name = name; this.type = type; this.dateCreated = dateCreated; this.employeeName = employeeName; this.employeeID = employeeID; } public void setName(String name) { this.name = name; } public String getName() { return name; } public void setType(String type) { this.type = type; } public String getType() { return type; } public void setDateCreated(Date dateCreated) { this.dateCreated = dateCreated; } public Date getDateCreated() { return dateCreated; } public void setEmployeeName(String employeeName) { this.employeeName = employeeName; } public String getEmployeeName() { return employeeName; } public void setEmployeeID(int employeeID) { this.employeeID = employeeID; }…The BankAccount class models changes to the balance of a person’s savings account. public class BankAccount { public BankAccount(String name, double initBal) public double getBalance() public String getName() public void deposit(double amount) public void withdraw(double amount) public void transferTo(BankAccount otherAcct, double amt) public boolean equals(Object other) private String acctName; private double balance; } Provide the code for the transferTo(…) Briefly explain why there is no setBalance() method in this class.Java. Refer to attachment. Starter code below. public class Car{//attributesprivate String make;private String model;private int year;protected int speed; //constructorpublic Car(String make, String model, int year){this.make = make;this.model = model;this.speed = 0;this.year = year;} //Getterspublic String getMake() {return make;}public String getModel() {return model;}public int getSpeed() {return speed;}public int getYear() {return year;}//Setterspublic void setMake(String colour) {this.make = make;}public void setModel(String colour){this.model = model;}public void setSpeed(int speed) {this.speed = speed;}public void setYear(int year) {this.year = year;}public void accelerate() {speed ++;} public void brake() {speed --;if (speed < 0) {speed = 0;} }public String toString() {String carDetails = "Make: " + this.make+ "\nModel: " + this.model+ "\nYear: " + this.year+ "\nSpeed: " + this.speed; return carDetails;}} public class NissanLeaf extends Car…