Write a program that simulates the Magic 8 Ball game. The class should have a method that returns an answer at random. Test your class by outputting the answer several times.
Q: Write a resource class that has the deposit, withdrawal, and print balance methods. Next, implement…
A: ## As no programming language is mentioned, the code is written in Python. class Resource:…
Q: Write a class RangeInput that allows users to enter a value within a range of values that is…
A: According to the information given:- we have to follow the instruction to get the desired outcome.…
Q: and changing the account detains of some banks, to stop this practice, you have been tasked to…
A: Algorithm: Start Create class Abaaneke with attributes name, deposit, oldBalance, newBalance…
Q: In this exercise, you are going to build on your Circleclass from the previous exercise. You are…
A: Modification to be done in the program: To add the areaDifference() method that returns the…
Q: Write a program by creating an 'Employee' class having the following methods and print the final…
A: /* Java program */import java.util.*; class EmployeeDetail { private String name; private float…
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 program which does the following: 1. Create a class with the main() method. 2. Take a string…
A: import java.util.*; class prog{ static int countNumberOfConsonants(String val){ String…
Q: Please Draw a Classifier with Name "Bank Transection" having a method with following statement "A…
A: Given : Method Name - Bank Transection Input parameter - Amount: Float Output parameter -…
Q: Consider the class Temperature below which has a static variable. What is the output of the main…
A: - We have to select the temperature which the code provides. - The options :: First option…
Q: Write the getSecond method for the Time class. It takes no arguments and returns an integer. This…
A: The getSeconds() method of Duration Class in java.time package is used to get the second value of…
Q: public class BackAccount { public double Balance { set; get; } public void Deposit(double amount) {…
A: //****************************************************************************** // File:…
Q: Add the following method to the Point class: public double distance(Point other) Returns the…
A: Solution: Programming language used: Java Program code for distance method - (Note: all…
Q: 3) Write a class called Point that represents a point in 2D plane. The constructor accepts the x and…
A: As I have read the guidelines I can provide answers to only 1 part of the questions in case of…
Q: This is wrong. Suppoeed to four method and call everything in main method. You can look at the…
A: We need to write a Java program for the given scenario.
Q: Q2: What happens when we write the following code in the main method: System.out.printIn("The video…
A: Objective: Given two program statements in Java. These code segments should be written in the main…
Q: Fill in the missing parts of the below method. The method is named calcMPG. It takes in two…
A: Given:- Fill in the missing parts of the below method. The method is named calcMPG. It takes in…
Q: Write a class called Investment with fields called principal and interest. The constructor should…
A: class Investment //Declaration of class Investment{ long principal,interest; //Declaring…
Q: Write a non-static method called average that accepts two integer parameters and returns their…
A: JAVA method average .To get average of numbers.
Q: Write a separate class BookDemo with a main() method that creates a Book object titled “Developing…
A: class Book{ private String name; private String author; private double price;…
Q: Write a class named PingPong that has a method next that alternates between printing 'PING' and…
A: Here is the python code: See below step for code.
Q: Write a program which does the following: 1. Create a class with the main() method. 2. Take a string…
A: Code: import java.util.Scanner;public class Main { public static void main(String args[]){…
Q: Write a program by creating an 'Employee' class having the following methods and print the final…
A: Create Employee class. Inside Employee class initialize variable salary and hours. Add Given…
Q: Write a class RangeInput that allows users to enter a value within a range of values that is…
A: CODE TEXT SO YOU DON'T HAVE TO TYPE. public class RangeInput { private int currentValue;…
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: Write a method that returns n! given an integer n. Your method must use and return a BigInteger…
A: From the given data, We need to write a method that returns n! given an integer n and the method…
Q: In this exercise, you are going to build on your Circleclass from the previous exercise. You are…
A: public class Circle { private double radius; public Circle(double theRadius) { radius =…
Q: Suppose there is a class called Thing and a method you attempt to call a method called myThing()…
A: there is a class called Thing and a method you attempt to call a method called myThing() like this:…
Q: We need to have a “class” createdcalled ROOMthat has width and lengthdefined. This represents a…
A: Program Approach:- It required class. Display the data members. Display constructor to initialize…
Q: Next, we want to start making enemies for our upcoming video game, so we will define a class called…
A: class GameEnemy has instance variables name, x, y, points and one constructor to set values to…
Q: Write a method named raiseSalary that accepts two integers as an argument and returns its sum…
A: Function:- public static double raiseSalary(int firstInt,int secondInt){ int…
Q: Write a static method called isEven that takes an integer as a parameter and returns true if the…
A: Program Approach: Import necessary libraries. Make a main method. Make a static method in it . Now…
Q: Write a Rectangle class to represent rectangles, with two data fields (width, height) and four…
A: Given: Write a Rectangle class to represent rectangles, with two data fields (width, height) and…
Q: Call the numberOfStudents method of that class. What does it do?
A: What does it do ? It will count the total number of students in particular class, and than return it…
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: Write method fullName with a return type of void and accept a name. The method will display the…
A: public static void fullName(String name) { String temp = " " + name; String newStr…
Q: Consider the BookArrayBag from slide #6 in the lecture-03-jan-28.pptx. Write an instance method…
A: Here is the answer:-
Q: You are given a Conversion class and need to complete it by adding two static methods. The first…
A: import java.io.*; public class Main { static double gallonsToPints(int gallon) {…
Q: Write a program which does the following: 1. Create a class with the main() method. 2. Take a string…
A: Java Code: import java.util.*; // Main classpublic class Main{ // Method that counts the number…
Q: Write a class called widget with an dollars; those values are passed in when a widget is created.…
A: class Widget: name = "" cost = 0 def __init__(self, name, cost): self.name =…
Q: What will be returned from the following method? public double testing ( ) {…
A: Answer: The following method(testing()) will return the value of 'a' which is 18.8.
Q: In Public Class, create a static void method called Info_AHW that takes 3 parameters - an int and…
A: Here I have created a function named Info_AHW(). In this function, I have created a print statement…
Write a
Step by step
Solved in 3 steps
- Write a method lastNameFirst that takes a string containing a name such as "Harry Smith" or "Mary Jane Lee", and that returns the string with the last name first, such as "Smith, Harry" or "Lee, Mary Jane".Write a new method for the atom class called ision that will return true or false, depending upon whether the atom is an ion. An atom is an ion if it is charged (i.e., if the number of electrons ≠ the number of protons).Write the code for the timeTick method in ClockDisplay that displays hours, minutes, and seconds, or even implement the whole class if you wish.
- For this problem you will write a method that computes the number of boxes in a pyramid of boxes based on the number of boxes in the base. The boxes in each layer of the pyramid are stacked directly on top of one another (i.e. not offset between two boxes below). For example, below are shown two pyramids, one with base 5 and one with base 6. [] [][] [][][] [][][][] [][][][][] [][][][][][] Implement and test the computePyramidBoxes() method in the PyramidBoxCount class. When testing the computePyramidBoxes() method you should be sure to have at least one test method for each base case and at least one test method for each recursive case in your program.What will be returned from the following method? public double testing ( ) { double a = 9.5 + 9.3; return a; }Write a method called average that accepts two integer parameters and returns their average as a double. Then write a second method that overloads the first method and takes 4 integers and returns average.
- Write a static method called isEven that takes an integer as a parameter and returns true if the integer is even and false otherwise.I am trying to add int instance variables for the current hour and minutes of a clock, and I am trying to make them private. I am also trying to write getHour and getMinutes getter methods for these instance variables. I would like to know if I did this correctly and if not, I would like assistance as to what I could change. public class DigitalClock { private int currentHour; private int currentMinutes; public int getHour() { return currentHour; } public void setHour(int currentHour) { this.currentHour = currentHour; } public int getMinutes() { return currentMinutes; } public void setMinutes(int currentMinutes) { this.currentMinutes = currentMinutes;}}Write a static method called larger that accepts two double parameters and returns the larger of the two values. If the values are equal, it doesn't matter which one is returned. JAVA
- Take a look at the header of the method below, and then implement a sample call to it in your code.empty public ShowValue ()You are given a Conversion class and need to complete it by adding two static methods. The first method should be called gallonsToPints and take a double gallons and return the number of pints as a double (1 gallon = 8 pints). The second method should be called feetToInches, also taking a double number of feet and returning the number of inches as a double (1 foot = 12 inches). Test your program in the ConversionTester class by printing out two conversions. In javaImplement a class that simulates a traffic light. The next method advances the color in the usual way, from green to yellow to red, then again to green. Provide two constructors, as described in the documentation of the public interface. Also supply a method that yields the number of times that this traffic light has been red. /** A simulated traffic light.*/public class TrafficLight{ private String color; private int reds; /** Constructs a green traffic light. */ public TrafficLight() { /* Your code goes here */ } /** Constructs a traffic light. @param initialColor the initial color "green", "yellow", or "red" */ public TrafficLight(String initialColor) { /* Your code goes here */ } /** Moves this traffic light to the next color. */ public void next() { /* Your code goes here */ } /** Returns the current color of this traffic light. @return the current color */ public String getColor() {…