how to make a scanner to get speed from the user and add the speed with the last value of the object for example Honda (speed+0.2)
Q: Write a Java class called Hotel that represents a hotel. The class will contain the following…
A: In java ArrayList can be resize as an array and it is present under util package. Example of…
Q: ANSWER IN JAVA Create a class called Date that includes three instance variables-a month (type…
A: This is a simple oops based question in java in which we have to create a date class and define…
Q: Write a Java class that would match a string. The class has method match with String as a return…
A: Coded using Java.
Q: Write the Boat class in Java Eclipse. A Boat has a registered name, a number of cabins, and a…
A: I give the code in Java eclipse as per your requirement along with code and output screenshot
Q: Write a complete Java class that can be used to create a Hamster object as described below: A…
A: The solution for the above given question is given below:
Q: Write a Circle Class that has the following fields: Radius: A double PI: A final double…
A: import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner…
Q: We simply need one method speak() to print out the way that the animal “speaks”. Put the method…
A: public interface Speakable { public void speak(); }
Q: Write a class for a Chicken that also implements your interface. The Chicken’s type will be…
A: Here in the section of chicken sound where the condition is that 50 % of time chicken will sound…
Q: write a java program A course has a name, a course number, a department code(for example, CS, MATH)…
A: Following is the java program that defines two class Course and XXX_TestCourse. Inside class Course,…
Q: Print the arrival time of the flight using a combination of methods from Flight and LocalTime • Read…
A: A flight object is created using parameterized constructor and then the changes are made and…
Q: Write a class for a Cow that implements your interface. The cow’s type can be “cow” and its sound…
A: I created a interface name of the interface is animal and a class which implements the interface…
Q: JAVA HELP PLEASE! Write a class Rectangle that has only the following public methods (you can add…
A: java is a programming language originally developed by James Gosling at Sun Microsystems (which is…
Q: Write a Java program: In the board game Scrabble, each tile contains a letter, which is used to…
A: toString() method returns a string with format: letter + " with value " + value. equals() method…
Q: REFER TO IMAGE (JAVA) a. Write a Java statement that increments the value of count by 1. b. Write…
A: public static int incrementCount() { // Here we are incrementing count by one , return count++; }
Q: e in java 1. Create a class called Student, with the following attributes/variables: a. studentName…
A: We need to create the Student and MyFriends classes as per the given description.
Q: Write a Java class called "Colors.java" that generates two random colors, then it applies a…
A: Below is the code in java and sample output:
Q: in JAVA Assume that a receipt id contains characters that represent information or that can be used…
A: Below I have provided a java program for the given question. Also, I have attached a screenshot of…
Q: Write a JAVA program which consists of a single class called BuyStuff that asks the user for two…
A: As we are dealing with amounts, displaying amounts with 2 point precision
Q: Write a class that has three overloaded static methods for calculating the areas of the following…
A: Please find the answer below
Q: Write a Java class called Power. This class defines a method called power() which takes as…
A: Algorithm: Start Create a class named Power Inside the class, implement a method named power()…
Q: Using java Hamburger Class Write a Hamburger class with the following six attributes: • bun - the…
A: Actually, in the program given attributes are: Hamburger class with the following six attributes:•…
Q: Write a Java program containing two classes: Dog and a driver class Kennel. The Dog class consists…
A: public class Dog { int age; String name; boolean hairLength; enum tail { LONG,…
Q: Write the Boat class in Java Eclipse. A Boat has a registered name, a number of cabins, and a…
A: The following is the source code for the given statements in the question.
Q: Suppose that a Scanner object contains a bunch of tokens all on a single line separated by spaces.…
A: Program code: //import the required packages import java.util.*; import java.lang.*; import…
Q: Write a ThreeWayLamp class that models the behavior of a lamp that uses a three-way bulb. These…
A: Given: Write a ThreeWayLamp class that models the behavior of a lamp that uses a three-way bulb.…
Q: in java write a class Vessel (2 methods, 2 properties ,one of them is speed). Extend this class into…
A: Purpose: In this we are considering a class vessel with all the conditions given and from that we…
Q: Hand-write a complete Java class that can be usedto create a Car object as described below.a. A…
A: Handwritten code is shown below -
Q: a project in Java and add the class Rectangle attached is a picture of the basic code for the…
A: It is defined as the programs can be asked from control statements, array, string, oops etc. Java…
Q: Create a new java project named CH46EX 1. Create a class named Student 1. 2 private instance data…
A: Working code: class student{ private String name; private long id; final static…
Q: Write a program to print the area of a rectangle by creating a class named “Rectangle” with…
A: // Create a class constructor for the Main class public Rectangle() { width = 0; //…
Q: Write a java program to help with the hospital. A Patient class, with class attributes of a patients…
A: I have written code in JAVA below:
Q: Write a Java program containing two classes: Dog and a driver class Kennel. The Dog dlass consists…
A: Given :- Write a love program containing two classes: Dog and a driver class Kennel.Dog class…
Q: Write a Java class named Book, which has a name, an author and a pub- lisher. This class must also…
A: public class Main{ public static void main(String[] args) { //create 2 books Book b1=new…
Q: For this assignment, create a child class of car that creates a car of a randomly generated color.…
A: //Adding the package package javafx.swing; //Importing the required header files import…
Q: **Java Code** Think Java Exercise 14.2 Write a loop that plays the game 100 times and keeps track of…
A: Given: Think Java Exercise 14.2 Write a loop that plays the game 100 times and keeps track of how…
Q: Create a subclass of Circle class ColoredCircle by implementing the ColoredShape interface. It…
A: Circle.java public class Circle { private double radius; private double area; private…
Q: Write Java Classes please read what's asked and dont add unnecassary parts In this problem, you…
A: Given : In this problem, you will create a shopping cart that will help a user keep track of bought…
Q: Java Program Following the example of the Circle class in Section 9.2, design a class named…
A: The Unified Modeling Language (UML) is a general-purpose, developmental, modeling language in the…
Q: In this exercise, you have to implement a calculator which can perform addition, subtraction,…
A: public class Calculator {double num1,num2; public Calculator( double num1,double num2) {…
Q: Implement a class RoachPopulation that simulates the growth of a roach population. The constructor…
A: class RoachPopulation{ private int population; //The constructor takes the size of the…
Q: rite Java Classes In this problem, you will create a shopping cart that will help a user keep track…
A: Write Java Classes In this problem, you will create a shopping cart that will help a user keep track…
Q: Build a simple lottery program that asks the user to input six numbers, prints those numbers, spins…
A: Build a simple lottery program that asks the user to input six numbers, prints those numbers, spins…
Q: Write a java program with the class name Vehicle. The class has three instance variables with names…
A: Basically, three classes are implemented. The Vehicle class is the base class and the Bus class is…
Q: Write a program in java. The Java class called Holiday is started below. An object of class…
A: public class Holiday { //declaring variables private String name; private int day; private String…
Q: Write a Java program containing two classes: Dog and a driver class Kennel. A dog consists of the…
A: ANSWER:-
Q: Write a complete Java class that can be used to create a Fish object as described below: A Fish…
A: public class Fish{ //Data members private String name; private int age; private String…
Q: You are given an interface AdvancedArithmetic which contains a method int divisor_sum(int n). You…
A: Java code: import java.util.*; //interfaceinterface AdvancedArithmetic { //abstract method int…
Q: Write a Java class called HotelRoom that represents a hotel room. The class will contain the…
A: Given: Write a Java class called HotelRoom that represents a hotel room. The class will contain the…
question for Java a class demo has three objects
Car car = new Car("make:Honda","color:Black",0.2);
Car car2 = new Car("make:Ford","color:blue", 0.5);
Car car3 = new Car("make:Tesla","color:silver",1.2);
how to make a scanner to get speed from the user and add the speed with the last value of the object for example Honda (speed+0.2)
Step by step
Solved in 2 steps with 2 images
- OBJECT ORIENTED IN JAVA Example for VERSION 1: Welcome to Nick's Neon Tubing Calculator Enter the shape type (R, S, C, T, L, Q): R Enter Height and Width of Rectangle: 6.5 12 The perimeter of a 6.5 x 12 rectangle is 37.0 Enter the shape type (R, S, C, T, L, Q): C Enter Diameter: 12 The circumference of circle with diameter 12 is 37.7 Enter the shape type (R, S, C, T, L, Q): Q Shapes Needed 37.0 - rectangle, 6.5 x 12 37.7 - circle, diameter 12 --------------------------- 74.7 Total Length Thank You there is a version 2 as well, if you look at the pictures. Every person I have asked to help has either not made it object oriented or that code did not work. PLEASE help.Eclipise Exercise 1: Write a Java application that simulates a test. The test contains at least five questions about first three lectures of this course. Each question should be a multiple-choice question with 4 options. Design a Test class. Use programmer-defined methods to implement your solution. For example: create a method to simulate the questions – simulateQuestion create a method to check the answer – checkAnswer create a method to display a random message for the user – generateMessage create a method to interact with the user - inputAnswer Display the questions using methods of JOptionPane class. Use a loop to show all the questions. For each question: If the user finds the right answer, display a random congratulatory message (“Excellent!”,”Good!”,”Keep up the good work!”, or “Nice work!”). If the user responds incorrectly, display an appropriate message and the correct answer (“No. Please try again”, “Wrong. Try once more”, “Don't give up!”, “No. Keep…JAVA Write an application to simulate the rolling of two dice. The application should use an object of class Random once to roll the first die and again to roll the second die. The sum of the two values should then be calculated. Each die can show an integer value from 1 to 6, so the sum of the values will vary from 2 to 12, with 7 being the most frequent sum, and 2 and 12 the least frequent.
- 2D Graphics You have learned 2D graphics from DrawPanel.java (see code below) // DrawPanel.java // Using drawLine to connect the corners of a panel. import java.awt.Graphics; import javax.swing.JPanel; public class DrawPanel extends JPanel { // draws an X from the corners of the panel public void paintComponent( Graphics g) { // call paintComponent to ensure the panel displays correctly super.paintComponent( g ); int width = getWidth(); // total width int height = getHeight(); // total height // draw a line from the upper-left to the lower-right g.drawLine(0, 0, width, height); // draw a line from the lower-left to the upper-right g.drawLine(0, height, width, 0); } // end method paintComponent } // end class DrawPanel 3. Write a Java program that does all of the following 3 actions. a. draws a line from (20, 50) to (50, x) of length 50. Compute the value x first. b. draws a rectangle with (20, 50) as the lower left corner, height 10 and width 100. c. fills a rectangle with (20, 50) as…You need 5 java classes and these include Netflix Class (Parent class of Movie and TVShow class) Movie Class TVShow Class Test/TestDriver Class Database Class Please read the questions carefully. TestDriver is given for the other image.Exercise 1: Write a Java application that simulates a test. The test contains at least five questions about first three lectures of this course. Each question should be a multiple-choice question with 4 options. Design a Test class. Use programmer-defined methods to implement your solution. For example: create a method to simulate the questions – simulateQuestion create a method to check the answer – checkAnswer create a method to display a random message for the user – generateMessage create a method to interact with the user - inputAnswer Display the questions using methods of JOptionPane class. Use a loop to show all the questions. For each question: If the user finds the right answer, display a random congratulatory message (“Excellent!”,”Good!”,”Keep up the good work!”, or “Nice work!”). If the user responds incorrectly, display an appropriate message and the correct answer (“No. Please try again”, “Wrong. Try once more”, “Don't give up!”, “No. Keep trying..”). Use…
- Create a java class name is Bugs that have Instance variables Constructors Automatic code generation Accessor Methods Mutator Methods move method turn method Bug Class: a bug has a code, original location at a point with integer coordinates, faces north, east,south, or west and keeps a record of all its current movement position. The class generate a uniquecode for each new “bug” object created starting with value “b-100”. It also includes the followingmethods:- A default constructor that initializes bug’s code to “b-xxx”; where “xxx” is the next codesequence number in the class, positions to (0,0), and direction to WEST.- A constructor that is given bug’s information: starting location, facing direction and generatesbug code similarly to the default constructor.- Accessor methods to access all the instance variables and the simulated movements of thebug.- Mutator methods that change the instance variables to given values and they make the changefor only suitable values.- turn method…Java class Main { publicstaticvoid main(String[] args) { // Coin myPenny = new Coin(CoinType.PENNY); // Coin myNickel = new Coin(CoinType.NICKEL); // Coin myDime = new Coin(CoinType.DIME); // Coin myQuarter = new Coin(CoinType.QUARTER); // Coin myHalfDollar = new Coin(CoinType.HALF_DOLLAR); // Coin myDollar = new Coin(CoinType.DOLLAR); // System.out.println(printValue(myPenny)); // System.out.println(printValue(myNickel)); // System.out.println(printValue(myDime)); // System.out.println(printValue(myQuarter)); // System.out.println(printValue(myHalfDollar)); // System.out.println(printValue(myDollar)); } publicstatic String printValue(Coin c){ String result = ""; // result = String.format("The value of a %s is $%.2f", c.getName(), c.getValue()); return result; } }Shape Class JAVA Implement the Shapehierarchy shown in figure below. Shape TwoDimensionalShape ThreeDimensionalShape Circle Square Sphere Cube Each TwoDimensionalShape should contain method getArea to calculate thearea of the two-dimensional shape. • Each ThreeDimensionalShape should have methods getArea and getVolume tocalculate the surface area and volume, respectively, of the three- dimensional shape. Add OneDimensionalShape with sub classes , and add more shapes to classes (TwoDimensionalShape , ThreeDimensionalShape ). Create a program that uses an array of Shape references to objects of each concrete class in the hierarchy. The program should print a text description of the object to which each array element refers. • Also, in the loop that processes all the shapes in the array, determine OneDimensionalShape, whether each shape is a TwoDimensionalShape or a ThreeDimensionalShape. If it is a TwoDimensionalShape, it is display ThreeDimensionalShape, display its area and volume. its…
- Transcribed Image Text JAVA Programming Problem: In the game of "Assassin's Creed", you control a ship with a cannon which is attacking a large enemy Assassin's Creed, armed with many guns. Your goal is to destroy as many of the guns as possible. The battle field is a 2D Cartesian grid, where your cannon is located at the origin. The enemy Assassin's Creed is a horizontal line segment located from the coordinates (X1, Y) to (X2, Y). There are exactly (X2 - X1 + 1) guns on the ship, located at the integer points (X1, Y), (X1+1, Y), ..., (X2, Y). However, the problem is, you cannot always fire at a gun. There are supernatural rocks located at all points of the battlefield whose X and Y coordinates are both integers. In order to fire successfully at an enemy's gun, the line connecting your cannon and that gun must not go through any rocks. Develop a JAVA code to output the number of the enemy battleship's guns that your cannon can destroy. Test Case Result 1 2 2 -2Create a sample program that uses type conversion and scanner class. Create a PHOTO ESSAY that shows how you are using the type conversion and Scanner class in java. Include at least 7 pictures with 30 to 50 words caption each.Online Billing System in Java This java project is based on calculating online bills without any manual calculation. The user just needs to feed the item name, its price, and quantity. The system will generate a bill showing the amount of money to be paid.