Exercise 3: A. Write static methods: public static double sphereVolume(double r) :ar public static double sphereSurface(double r) : 47r² public static double coneVolume(double r, double h): - thr2 public static double coneSurface(double r, double h) :ar(h +r) that compute the volume and surface area of a sphere with radius r, and a cone with cireular base with radius r and height h. Place them into a class "Geometry2.java". Then write a program with main class called Lab7_yourlD.java" that prompts the user for the values of r and h, calls the four methods, and prints the results.
Q: Basic Java please Write a method called torusVolume(? littleR, ? bigR) that takes an int littleR and…
A: Task : Write a Java program to calculate the torus volume. Java Program :- class Main { //…
Q: Write a class method to convert inches to centimeters (use double types, and note that 1 inch =…
A:
Q: The weight of an object can be described by two integers: pounds and ounces (where 16 ounces equals…
A: Program Plan: Implement a compareTo method as follows: Call and return the compare function with…
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: 21. Consider the following method: public static void sketch(int x1, int y1, int x2, int y2, int n)…
A: Given method call: sketch(a, 0, -a, 0, 2) x1=a y1=0 x2=-a y2=0 n<=0 i.e 2<=0 (False)…
Q: Python: implement a class called point, the class contains two values of a type of integer (x and…
A: The main objective of the program is to create a point class. The point class has two variables x…
Q: Given class Triangle, complete the program to read and set the base and height of triangle1 and…
A: You have to accept input from user rather than hardcoding and this is what we replaced here…
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 a class that has three overloaded static methods for calculating the areas of the following…
A: Create 3 methods with the same name but with different arguments to overload the methods. Use the…
Q: 3. Charge Account Validation Create a class with a method that accepts a charge account number as…
A: The Above code ios solved in Java Programming below:
Q: Write a python program to define a class (Clock) with the following members: > Attributes: hours:…
A: class clock: def __init__(self): self.hours = 0 self.minutes = 0…
Q: Exercise 2: A. Write static methods: public static double cubeVolume(double h) : h3 public static…
A: The Java OOPS code to do the job described in problem statement is: Part A) Keeping cube, Cylinder…
Q: IN C++ Implement a class Car with the following properties. A car has a certain fuel efficiency…
A:
Q: Exercise 3: A. Write static methods: • public static double sphereVolume(double r) : r³ • public…
A: Here I have created a class named Geometry. In this class, I have created all 4 methods and then…
Q: Write the appropriate method headings using the provided method name for the following processes 1.…
A: Here in the code as specified in the code the method can be taken as the printArea to print the area…
Q: 21. Consider the following method: public static void sketch(int x1, int y1, int x2, int y2, int n)…
A: The question is to choose the correct option for the given question.
Q: Identify the user-defined method based on the program given below. public class Mark { int mark1,…
A: Here, public int set (int m1, int m2) is the user-defined method. So, the correct option is given in…
Q: Write a class that has three overloaded static methods for calculating the areas of the following…
A: Please find the answer below
Q: 3. Write a java program as in the next class diagram, such as: SimpleCalc2() method only calls find…
A: java code
Q: Write code for a Java class Rectangle with the following fields and methods: Rectangle - width :…
A: /** File: Rectangle.java** Summary of file:* * This file contains the Rectangle class* with all the…
Q: class Geometry
A:
Q: Question:Write the method in java for following a)Method returns a translated point b) Method…
A: a. Java Translated point I Know there is this method; pt.translate(int x, int y); But is there this…
Q: 1/ Implement a class Employee. An employee has a name (a string) and a salary (a double). Provide a…
A: Note: This is a multiple-question-based problem. The only first question is solved. Kindly send the…
Q: Write static methods: public static double sphereVolume(double r) :-ar public static double…
A: Only the first question will be answered since two questions are asked. please upload second part…
Q: b) Write the static method dayOfWeek, which returns the integer value representing the day of the…
A: The dayOfWeek method internally depends on int firstDayOfYear(int year) method int dayOfYear(int…
Q: Consider the following classes: public class Topl int x; public Top (int x) { this.x = x + 1; }…
A: What will be displayed on screen from the Java code?
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 Python Program Implement the design of the Traveller class so that the following output…
A: 1) Below is program that implements the design of the Traveller class so that the following output…
Q: A. Write static methods: public static double cubeVolume(double h) : h3 public static double…
A: GIVEN: 1) Create a class geometry and place four methods inside the class. The four methods are…
Q: 9. Write a Class Called myMath which has three Methods has the same name TriangleArea (overloaded…
A: Take input of the three sides of the triangle from the user and store them in the variables a, b and…
Q: 21. Consider the following method: public static void sketch(int x1, int y1, int x2, int y2, int n)…
A:
Q: ) Implement a class Point with three attributes, x, y, and z. b) Implement an init method with an…
A: GIVEN: Create a program for the above question. NOTE: As programming language is not mentioned, we…
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: Write static methods: public static double cubeVolume(double h) : h3 public static double…
A: Two questions are asked so we will give you the answer to the first question only. Please upload…
Q: In the main method add the following declarations: int[ ] arr1 = {1,2,3,4,5,6,7,8,9,10}; int[ ]…
A: int[ ] arr1 = {1,2,3,4,5,6,7,8,9,10}; //initializes arr1 int[ ] arr2 =…
Q: Complete method area in the following class. All it needs is a return statement. 1 class Rectangle:…
A: class Rectangle: width = 0.0 height = 0.0 def __init__(self, w, h): self.width =…
Q: A Given the following code, what is the output? Assume a public number instance variable, and a…
A: Dear student, I'm providing the output as well as an explanation as per your requirement. I hope…
Q: Exercise 2: A. Write static methods: public static double cubeVolume(double h) : h3 public static…
A: public class Geometry { public static double cubeVolume(double h) { return h * h * h;…
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: Write static methods: • public static double cubeVolume(double h) : h! • public static double…
A: Here are the 2 classes ======================================================================…
Q: Computer Science Write a program for a toy-car manufacturing plant. Assuming that 10 toy-cars can…
A: According to the information given:- We have to follow the instruction to get bill for the customer…
Q: The weight of an object can be described by two integers: pounds and ounces (where 16 ounces equals…
A: Source Code Weight.java public class Weight{ private int pounds; private int ounces;…
Q: Import Class a) Implement a class Rectangle with two attributes, width and height. b) Implement an…
A: Note: Answering the first three subparts as per the guidelines. Task : Define class name Rectangle…
Q: A. Write static methods: public static double sphereVolume(double r) : =tr³ public static double…
A: import java.util.Scanner; public class Lab7_yourID{ public static void main(String[] args) {…
Q: Lets say that class Laptop has been implemented. In order to compare two laptops a compareTo method…
A: The answer of this question is as follows:
Q: Given class Triangle, complete the program to read and set the base and height of triangle1 and…
A: Actually, python is a easiest programming language. It is a dynamically typed programming language.
Q: Write java method fullName with a return type of void and accept a name. The method will display the…
A: Java code:- import java.util.*;public class Main { static void fullName( String fName) {…
Q: Consider the following design for a Product class that keep track of product inventory:
A: 1. Create two product soft roll with name soft roll and quantity 25 and Hard rolls with name Hard…
Q: The following is in Java: public class MyClass { private int x; private double y;…
A: Defined the given Java code
Q: Exercise 2: A. Write static methods: public static double cubeVolume(double h) : h public static…
A: Below is the required Java program: - A. Program: - //Import the package import java.util.Scanner;…
write easy java programs
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- Write static methods* public static double cubeVolume(double h)* public static double cubeSurface(double h)* public static double sphereVolume(double h)* public static double sphereSurface(double h)* public static double cylinderVolume(double h)* public static double cylinderSurface(double h)that compute the volume and surface area of a cube, sphere, and cylinderPlace them in a class GeometryUse the given tester file to test your calculationsThis question was rejected from incompletion but it's completed. Answer the prompt with the following code as a guide for the main method: import java.awt.*; public class TestRectangle { public static void main(String[] args) { Rectangle r1 = new Rectangle(5, 4, 10, 17); Rectangle r2 = new Rectangle(10, 10, 20, 3); Rectangle r3 = new Rectangle(0, 1, 12, 15); Rectangle r4 = new Rectangle(10, 10, 20, 3); System.out.println("r1 = " + r1); System.out.println("r2 = " + r2); System.out.println("r3 = " + r3); System.out.println("r2 equals r1? " + r2.equals(r1)); System.out.println("r2 equals r2? " + r2.equals(r2)); System.out.println("r2 equals r3? " + r2.equals(r3)); System.out.println("r2 equals r4? " + r2.equals(r4)); System.out.println("r1 contains (6, 8)? = " + r1.contains(6, 8)); System.out.println("r2 contains (6, 8)? = " + r2.contains(6, 8));…java program Write the equals method for Circle2 which returns true when the radius and the color are the same as the parameter’s radius and color. The TestCircle2, Circle2 and GeometricObject2 classes are given as follows. public class TestCircle2 { public static void main(String[] args) { Circle2 c1 = new Circle2(2.3, "red"); Circle2 c2 = new Circle2(5.6, "white"); Circle2 c3 = new Circle2(2.3, "red"); System.out.println("c1 equals c2: " + c1.equals(c2)); System.out.println("c1 equals c3: " + c1.equals(c3)); System.out.println("c2 equals c3: " + c2.equals(c3)); } } class Circle2 extends GeometricObject2 { private double radius; public Circle2() { } public Circle2(double radius) { this.radius = radius; } public Circle2(double radius, String color) { this.radius = radius; setColor(color); } /** * Return radius */ public double getRadius()…
- 4.2.3: Method definition: Volume of a pyramid. Define a method pyramidVolume with double parameters baseLength, baseWidth, and pyramidHeight, that returns as a double the volume of a pyramid with a rectangular base. Relevant geometry equations: Volume = base area x height x 1/3Base area = base length x base width.(Watch out for integer division). import java.util.Scanner; public class CalcPyramidVolume { //answer goes here// public static void main (String [] args) { Scanner scnr = new Scanner(System.in); double userLength; double userWidth; double userHeight; userLength = scnr.nextDouble(); userWidth = scnr.nextDouble(); userHeight = scnr.nextDouble(); System.out.println("Volume: " + pyramidVolume(userLength, userWidth, userHeight)); }}You can just provide code as you don't have required utility class, Please provide explanation and comments for code : Write a static method asciiGraph(), to display a “graph” of ASCII values of a String. 2.The method has a single String parameter str, and returns nothing (void).3.The method loops through all characters in str, and for each displays a line of *s on a row equal to the ASCII/Unicode integer value of the character being examined (see example).Hints:1. recall the String methods .charAt() and .length(), and casting a char with (int) directly returns the int ASCII/Unicode value2. to produce the line of *s, call the method starLine() from the Exam utility class3. in the output capture document, consider reducing the font size to 7 or 8 point to have each row of *s on a single line Consider the strings “Ab C” and “TED 99”, that are composed of:A displays 65 stars (*), since Unicode 65 = 'A'b 98 stars (*), since Unicode 98 = 'b'space 32 * , since Unicode 32 = ' ' (the space)C…The Java code provides a Class named Function in Function.java that has a static method named f that takes a double argument and returns the value of . It also has a static method named fprime that takes a double argument for x and returns the value of the slope of f(x). The slope of f(x) can be calculated as . Implement this method. public class Function { public static double f(double x) { return Math.pow(x,3) - 3 * x; } public static double fprime(double x) { // your code goes here } }
- Write the equals method for Circle2 which returns true when the radius and the color are the same as the parameter’s radius and color. The TestCircle2, Circle2 and GeometricObject2 classes are given as follows. public class TestCircle2 { public static void main(String[] args) { Circle2 c1 = new Circle2(2.3, "red"); Circle2 c2 = new Circle2(5.6, "white"); Circle2 c3 = new Circle2(2.3, "red"); System.out.println("c1 equals c2: " + c1.equals(c2)); System.out.println("c1 equals c3: " + c1.equals(c3)); System.out.println("c2 equals c3: " + c2.equals(c3)); } } class Circle2 extends GeometricObject2 { private double radius; public Circle2() { } public Circle2(double radius) { this.radius = radius; } public Circle2(double radius, String color) { this.radius = radius; setColor(color); } /** * Return radius */ public double getRadius() {…Define a method printAll() for class PetData that prints output as follows with inputs "Fluffy", 5, and 4444. Hint: Make use of the base class' printAll() method. Name: Fluffy, Age: 5, ID: 4444 // ===== Code from file AnimalData.java =====public class AnimalData {private int ageYears;private String fullName; public void setName(String givenName) {fullName = givenName;} public void setAge(int numYears) {ageYears = numYears;} // Other parts omitted public void printAll() {System.out.print("Name: " + fullName);System.out.print(", Age: " + ageYears);}}// ===== end ===== // ===== Code from file PetData.java =====public class PetData extends AnimalData {private int idNum; public void setID(int petID) {idNum = petID;} // FIXME: Add printAll() member function /* Your solution goes here */ }// ===== end ===== // ===== Code from file BasicDerivedOverride.java =====import java.util.Scanner; public class BasicDerivedOverride {public static void main(String[] args) {Scanner scnr = new…python pleaseWrite a class called Point that represents a point in 2D plane.- The constructor accepts the x and y dimensions of the point.- Provide a method getX that returns the x coordinate of a point, and another method getYthat returns the y coordinate of a point.- Provide a method called translate that changes the original coordinates of the point byadding a given values for x and y coordinates.- Provide a method distanceTo that calculates the distance between that point and anotherone.Use this equation to calculate the Distance math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2))While the math is a library you should import. Where the (x1, y) is the coordinates of the first pointand (x2, y2) is the coordinates of the second pointThe output should be like this screenshot.
- Define a Static method 'max' with return type as 'int' in class 'ProblemSolution' that take two numbers with type 'int'. Inside the 'max' method, compare the two numbers and return the maximum of the two numbers. Then, inside the 'main' method. Define two 'int' type numbers; the first number (num1) is equal to 5 and the second number (num2) is equal to 2. At the next line, call the 'max' method where its parameter input are the two numbers above, and assign the result of the method to the variable num3 (type 'int'). Finally, on the next line, print out -> "The maximum of " + num1 + " and " + num2 + " is " + num3 Output The maximum of 5 and 2 is 5 Where, There must be space between all the words and numbers. There should not any space after the last numberBasic Java please Write a method called torusVolume(? littleR, ? bigR) that takes an int littleR and an int bigR in as parameters. Use the two values to find and return the volume as a double of the associated regular octagonal prism. The formula for the volume of a torus is (2πR)⋅(πr^2)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.