All or Nothing Implement a public class named All that provides a single static method name orNothing. orNothing accepts two parameters: a count (int) and a boolean and returns an array of Items of size count. If the passed boolean is true you should return an array where all references refer to the same Item. If the passed boolean is false you should return an array where all references refer to different Item instances. You can create Item instances with an empty constructor: new Item().
Q: public interface Rational { /** * Determines whether this Rational object represents a value less…
A: I give the code in Java along with output and code screenshot
Q: using java wride a program Consider the following class definition: public class date { private int…
A: import java.util.Scanner;public class OurDate { private int day; private int month; private int…
Q: Create a class Bookwhich describes its book_titleand book_price. Follow the below steps,a.Use getter…
A: Algorithm: Start Create a class named Book with book_titleand book_price as its attributes…
Q: Q2. Write two Java classes: Student and Main as follow: Class Student: A. Create three private…
A: A class is a user-defined data type that combines data members and methods for manipulating that…
Q: 1. Write a class "Ball" which extends the class disk. It has deltax and deltay attributes. 2. Write…
A: Code in Java Language : - class disk { } class Ball extends disk { private int deltaX, deltaY;…
Q: Data Structure Add three methods to the following class
A: The static method add() takes two polynomials p1 and p2 as parameter. It finds the max matching…
Q: (The ComparableSquare class) Define a class named ComparableSquare that extends Square and…
A: Java code in step 2:
Q: uestion) class Player: total_player = 0 def __init__(self,name,country):…
A: Design TennisPlayer class which inherit from Player class so that the following code provides the…
Q: 2. Import Class a) Implement a class Rectangle with two attributes, width and height. b) Implement…
A: class Rectangle: width = 0 height = 0 def __init__(self, width = 1, height = 1):…
Q: Design a class Bank that contains a number of bank accounts. Each account has an account number and…
A: These programs can be asked from control statements, array, string, oops etc. Java basic programs…
Q: Write in python. Write a class named Employee that has **private** data members for an employee's…
A: The Complete Python code is given below with code and output screenshots Happy Coding ?
Q: lass contains three independent static methods and contains no fields (none should be added). The…
A: It is defined as a user defined blueprint or prototype from which objects are created. It…
Q: public class BankAccount implements Deposit, Withdraw {...} public interface Deposit {public void…
A: Below is the answer with explanation:
Q: write a class called rectangle that implements the Comparable The class should contain three fields:…
A: import java.util.*;//1. definition for Class Rectanglepublic class Rectangle implements…
Q: This program should be written in Java: Hamburger Joint: Hamburger Class Write a Hamburger class…
A: import java.util.*;public class Hamburger { String type; int patties; int cheese; double price;…
Q: 1. Write a class "Ball" which extends the class disk. It has deltax and deltay attributes. 2. Write…
A: I have provided the answer based on Java Programming. Detailed comments are included for a better…
Q: Follow the steps below to create a concrete class SortedArray with required instance variables and…
A: Solution - Programming language used - Java All necessary comments are included in program code.…
Q: 1. Rainfall Class Write a RainFall class that stores the total rainfall for each of 12 months into…
A: The program should have methods that return the following: The total rainfall for the year The…
Q: solve this by arraylist in the last of the question it has been told Create abstract class Pet ,…
A: Program: //Pet.java//Pet abstract classpublic abstract class Pet { private int legs; //Constructor…
Q: Write the classes as shown in the following class diagram. Add a tester where you make an array of 5…
A: Java is an object-oriented language, it is used to develop browser applications and mobile…
Q: Write a PaypalAccount class to include both balance and accountID as the instance variables. Make…
A: Java is a programming language was originally developed by James Gosling at Sun Microsystems.
Q: Consider the class Array below that encapsulates an array of integers. Add a member method…
A: In this problem statement need to find the smallest value in the array. Array class created…
Q: Write an equals method for the StepsFitnessTracker class that tests whether the one object is equal…
A: Actually, program is a executable software that runs on a computer.
Q: Write a class called Rectangle that implements the Comparable The class should contain three fields:…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: Write an equals method for the StepsFitnessTracker class that tests whether the one object is equal…
A: Actually, program is a executable software that runs on a computer.
Q: Assume ContractEmployee, HourlyEmployee, CommissionEmployee, FixSalaryEmployee are sub-classes of…
A: Given question has asked to create a method Static void countAndPrintAllTypesOfEmployee which will…
Q: Write a method with the name "eraser" that will get two arguments: “maparr_plants" (Map array of…
A: Here we have to provide the key for containsKey and remove methods not the indices. So the updated…
Q: a class (an class to it) encapsulates the ales tax rates in the 50 U.S. states over the last 10…
A: Given Write a class (and a client class to test it) that encapsulates the evolution of the sales tax…
Q: Extend the ItemToPurchase class to contain a new attribute. item_description (string) - Set to…
A: Below is the required python program: - Program: - #Define the class ItemToPurchase class…
Q: 3. Import Class a) Import pi only from math module. b) Implement a class Circle with an attribute,…
A: code is in next step:
Q: Create a generic class with a type parameter that simulates drawing an item at random out of a box.…
A: USING JAVA 5 :-
Q: Class Employee Attributes (all private): id: String lastName: String firstName: String salary: int…
A: Code to Copy: Employee.java: //Import the required packages.import java.text.DecimalFormat;import…
Q: Write the Circle class:• A Circle has a radius– Add instance variable– 2 constructors – one should…
A: Create a class Circle and define it's instance variable as private type and just declare default…
Q: Design TomCruise class and DulquerSalman class which inherit from Actor class so that the following…
A: 1) Below is program which design TomCruise class and DulquerSalman class which inherit from Actor…
Q: Implement a public class named All that provides a single static method name orNothing. orNothing…
A: The solution code for the above problem can be found in Step 2. The solution code is provided using…
Q: Note: It`s python coding 1. Class Implementation a) Implement a class Rectangle with two…
A: class Rectangle: # a class Rectangle def __init__(self,…
Q: Read the quistion entirely before ansewring the code should compile and run Create a java class…
A: import java.util.Scanner;import java.util.*;import java.lang.*;public class Question2{public void…
Q: Write a program to create a class employee, it consist of ID, name, department and address. All…
A: Code: #include <windows.h>#include <iostream> using namespace std; class employee{ int…
Q: Q1: Write the Java code corresponding to the following UML diagram. The class School implements the…
A: Algorithm: Start Implement an interface Building with methods computeArea() and toString() Create a…
Q: Revise a MarketPlace class in PYTHON that allows users to buy/sell stocks. It will match buyers with…
A: I have answered this question in step 2.
Q: 2. Implement the class billBook using the above UML: a. Write the constructor that takes as…
A: Here I written Java code for given problem. I hope you like it. with implements of billBook also…
Q: Consider the class Account (Assume the class is given, do nat write the class melhods). The Account…
A: //Bank account classpublic class account {private int ANumber;private double balance; public…
Q: Implement the above system using inheritance in the best possible way. Keep every object size as…
A: The given system of classes for inheritance are implemented as follows: Class Region acts is…
Q: Import Class a) Import pi only from math module. b) Implement a class Circle with an attribute,…
A: In this question we have to write a python code class program with circle and rectangle classes with…
Q: Home Task: 1. Implement the following class and test its methods: Fraction - numerator: int -…
A: Code In Java:…
Q: Write two Java classes: Student and Main as follow: Class Student: A. Create three private…
A: (1)First we need to define a Student class with the attributes Name, ID and Specialization (2)In…
java language - please help
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images
- c# programMake a class called Employees, with attributes Name, Gender, Experience, Salary and ID.Make a delegate called EligiblePromo. This delegate takes an employees object as a parameter and returns a boolean value indication whether or not the employee should be promoted.Make a PromoteEmployee() method that takes an arraylist of Employees and delegate of type EligiblePromo as parametersNB: PromoteEmployee() methos loops through each Employees object and passes it to the delegate(25)public class TestStudents { public static void main(String[] args) { //2.2 Code given to you. Just use them. //create an array of Student objects. Student[] cisDept = new Student[4]; //Create and add 4 students, two undergraduates, two master students // add these students to the array //They are commented since you haven't added your code to Undergraduate, MasterStudent /* String[] theisCommittee = {"Tom", "Richard", "Gene"}; cisDept[0] = new MasterStudent("222", "Steve", "Jobs", "IST", "MS", 3.5, "How to make ipad smarter", "Jamie", theisCommittee); cisDept[1] = new Undergraduate("444", "Bill", "Gates", "CS", "BS", 3.0, "Erin", "Sally"); String[] theisCommittee2 = {"Jie", "Zoran", "Gene"}; cisDept[2] = new MasterStudent("333", "Amy", "Jobs", "CS", "MS", 3.8, "Study of Robots That can Perform", "Eduard",…Java Program The assignment requires two classes. Put all classes in the same package. Class Employee Attributes (all private): id: String lastName: String firstName: String salary: int Methods: Parameterized constructor for initializing a new Employee instance Getters for all attributes toString method to display an Employee's attributes (See output of executable below) Executable Class Create an array of at least eight Employee objects. Be sure to use many with identical last names, but don't order them by name in the array. Create an ArrayList from the array. Sort the ArrayList first by last name and then by first name. Using the forEach method and a lambda expression, print all employees alphabetically sorted by name. Create a LinkedList from the ArrayList. Create an iterator capable of cycling both forward and backward through the LinkedList. Iterate forward through the LinkedList without generating any output. Then iterate backwards through the LinkedList to print…
- 1. Square Roots Create a class with a method that, given an integer, returns an array of double-precision floating point numbers (known in Java as double), each of which is a square root of a number between 2 and the parameter to the method. For example, if the parameter is 5, the method should return an array of 4 doubles, with approximate values 1.4142135623, 1.7320508075, 2.0, and 2.2360679774. Your method should check the validity of the parameter, and take appropriate action if the parameter is invalid. 2. Reading Files Create a class with a method that, given a string representing a file name, returns an integer with the number of characters in the file. For example, if the file has 10 characters, your method must return the number 10. 3. Main Class Create a class HW1.java with a main method that does both of the following: calls the method from part 1 with a random integer between 0 and 10, and prints each of the numbers in the result. The numbers should all be printed on the…Write a class that represents a player in a game. The player should have a name, password,experience points, an inventory array of four strings, and a location x,y. Your class shouldhave mutator and accessor methods for all variables. For example: setName(), getName(). Itshould have a suitable display method. Mutators and accessors should be public but allvariables should be private. To implement get inventory, use string * getInv(); Use the scoperesolution operator to implement larger methods such as display(). Use in class methods forshorter methods such as setName(), getName(). (in C++)Example:void setName(string name){this->name = name;}string *getInv();...string* player::getInv(){return inventory;}Note that in the above method setName “this->” is required for disambiguation. If writtenvoid setName(string n){name = n;}“this->” is not required.Write a test program that creates three players and displays them.Example Output:This program generates three player objects and…The Delicious class – iterative methods The Delicious class must:• Define a method called setDetails which has the following header: public void setDetails(String name, int price, boolean available) This must find in the ArrayList the Chicken with the given name, change itspricePerKilo to the given price parameter and set whether it is in stock or not. A value of true for the available parameter means the chicken is in stock and a value of false means it is sold out (not in stock). Note that there will only be at most one Chicken object of the given name stored in the ArrayList.• Define a method called removeChicken that takes a single String parameter representing a chicken’s name. This method must remove from the ArrayList the Chicken object (if any) with the given name. The method must return true if a cheese with the given name was found and removed, and false otherwise.The Delicious class – challenge method In the Delicious class complete the findClosestAvailable method: This…
- Create a class Term. This class represents a term ofa polynomial such as 2x4 where 2 is coefficient and 4 isexponent of the term.Data members:- int coefficient int exponentCreate another class Polynomial. The internalrepresentation of a polynomial is an array of Terms. Thesize of this array should be fixed.Provide a constructor for this class that will set all termsof a polynomial object as zero (where coefficient is 0 andexponent is 0). Provide followingfunctions: setTerm(int, int) – Setting a term of a polynomialobject. Each successive call of this function shouldset next term of the polynomial object.It should do the following validations:- Whether the exponent of the term being set isalready used. Whether the array size limit is exceeded. Whether the exponent is negative.In all the cases it should not set the term and display anappropriate message. sort() – to arrange the terms in ascending order ofexponents. provide a function to print a polynomial objectCreate a class called Employee with threeattributes: Name, Salary and Id. Make constructors, getters, setters, tostring, displayand compareTo methods. Write a method qsort(e) that will accept an array ofEmployees and sort the results by ID. Write a method bsearch(e, id) that will accept asorted array of Employees and use a binary searchalgorithm to find a specific employee by Id.In your test driver create an array with 10employees. Be sure to populate that data sothat the ids are in random order. Display the array, call qsort then display it again andcall the bsearch with a valid id and an invalid id.Write a class named StockPrice. The class constructor should accept an array of stock prices as its argument. The class should have a method that returns the average of the stock prices. If any stock prices in the array is at least 300, the class should throw an IllegalArgumentException.
- 10.5 LAB: Count probations (EO) Students are put on probation if their GPA is below 2.0. Complete the Course class by implementing the countProbation() method, which returns the number of students with a GPA below 2.0. Given classes: Class Course represents a course, which contains an ArrayList of Student objects as a course roster. (Type your code in here) Class Student represents a classroom student, which has three fields: first name, last name, and GPA. Hint: Refer to the Student class to explore the available methods that can be used for implementing the countProbation() method. Ex: If the following students and their GPA values are added to a course: Henry Cabot with 3.2 GPABrenda Stern with 1.2 GPALynda Robison with 3.3 GPAJake Flynn with 1.8 GPA then the countProbation() method returns 2 and the program output is: Probation count: 2 Course.java import java.util.ArrayList; public class Course { private ArrayList<Student> roster; // Collection of Student…Consider the Person class below: public class Person { private String name; private int age; public Person () { } public void setAge(int age) { this.age = age; } public void setName(String name) { name = name; } public int getAge() { return age; } public String getName() { return name; } } Create an object of type Person with name, John, and age 25. Create a one dimensional Array of Person objects, people, which can hold 100 Person objects: Write the sumAge method. It calculates the total age of all the Person objects in the people array. public static int sumAge(Person [] people) { }Your Question: Chapter 7. PC #1. Rainfall Class Write a RainFall class that stores the total rainfall for each of 12 months into an array of doubles. The program should have methods that return the following: • the total rainfall for the year • the average monthly rainfall • the month with the most rain • the month with the least rain Demonstrate the class in a complete program. Main class name: RainFall (no package name) PLEASE MODIFY THIS CODE SO WHEN I UPLOAD IT TO HYPERGRADE IT PASSES THE TEST CASES. IT HAS TO PASS THE TEST CASES BECAUSE WHEN I UPLOAD IT TO HYPERGRADE IT DOES NOT PASS THE TEST CASES. I HAVE PROVIDED PROOF OF THE PART OF THE TEST CASE THAT FAILED. import java.util.Scanner;public class Rainfall { double rain[]; public Rainfall() { rain = new double[12]; } public double averageRainfall() { double number = getTotalRain() / 12.0; double roundedNumber = Math.round(number * 10.0) / 10.0; return roundedNumber;…