Write a Java program to solve quadratic equations.
Q: Design a class named Complex for representing complex numbers with the methods add, subtract,…
A: the answer is given below:-
Q: 2. Here is the API for a robot library. // moves the robot forward function moveForward(); // turns…
A: Explanation: If bottom-leftmost block is labelled as (0, 0), The operations in option A will make…
Q: Write a Java program to solve quadratic equations. • Design a class QuadraticRoots which has…
A: ALGORITHM:- 1. Take input values of a, b, c from user. 2. Set the values of a, b, c using setter. 3.…
Q: Write a class called quadrilateral. Your task is to store the length of all the sides of the…
A: File: Quadrilateral.java class Quadrilateral{ private int s1; private int s2; private int…
Q: In Java, implement Abstraction in the grading system. Include three different implementation methods…
A: Below i have answered:
Q: Design a Java class named LinearEquation for a 2-by-2 system of linear equations: ax + by = e…
A: the code is given below: given: The class contains:• Private double data fields a, b, c, d, e, and…
Q: For the following above code snippets, identify whether the code:
A: Solution 1a) It fails to Compile Reason: AnimalHouse<Cat> and AnimalHouse<Animal> are…
Q: Implement a program for the class Hospital. 1) The class Hospital has two data members, a string…
A: In class Hospital: Create a pointer of string using char** pointer. Create a string variable to…
Q: Design a class named LinearEquation for a 2-by-2 system of linear equations: ax + by = e…
A: given: The class contains:• Private double data fields a, b, c, d, e, and f.• A constructor with the…
Q: Write a class called quadrilateral. Your task is to store the length of all the sides of the…
A: Code: class Quadrilateral{private int side1;private int side2;private int side3;private int side4;…
Q: (1) Implement the class A- Write a C++ program to define a class QuadraticEquation described as…
A: Algorithm: Start Define class QuadraticEquation with private members a,b,c Define get and set…
Q: Q4. Apply the dynamic programming which studies in the class to make change for an amount N=10 using…
A: Please upvote. I am providing the correct answer below. This problem is a variation of the…
Q: * A class to represent a triangle defined by the x- and y-coorindates of its * three corner points…
A: The answer is follows.
Q: Define a Python class to represent a geometric solid cube. The following are your requirements:…
A: Programs: Programs are used to provide instruction to the computer to solve a particular problem.…
Q: Please dont copy and paste and give proper explanation. Suppose that a Java implementer is required…
A: // the parent class class Person { // general member variables String firstname; String…
Q: The mathematician Conway imagined a game, called game of life, which considered cells that are…
A: Conway imagined game Coded in PYTHON Programing
Q: Write the following program in python; There is a class with m number of students and they have n…
A: Objective: This program develops a class with an 'm' number of students and an 'n' number of…
Q: Implement a composition relationship between any two class types from the following list: Address…
A: class Name { private: string name; public: Name() {} Name(string name) {this->name =…
Q: Using Python, create a program that has the following classes: Point - Just like in the lecture,…
A: Solution - Programming language used: Python All solution steps are included in program code as…
Q: Write a Program to define a PhoneNumber class, with member variables int nationalCode( e.g 92/0 for…
A: Step 1 : import java.util.*; it will import all the class in util package we required Scanner class…
Q: When a recursive call is encountered, computation is temporarily suspended; all of the information…
A: Given : TRUE OR FALSE 1. When a recursive call is encountered, computation is temporarily suspended;…
Q: Modify the given codes to remove the compilation errors. 1. public interface Carnivore {…
A: Answer: Ans-1: The code will not compile and it will be given you the two compile-time errors…
Q: Solve the programming exercise P9.9 on Page 490 on the book. Make a class Employee with a name and…
A: public class Employee{ //declaring instance variables private String name; private double…
Q: Consider the following declaration of class Quad and answer the question below. class Quad int x0,…
A: A class template provides a specification for generating classes based on parameters. Class…
Q: Analyse the following Java code segment and answer the questions that follow: 1| interface Steerable…
A: Every program is written using some building blocks which are called programming constructs. The…
Q: 1. How can we write a parameter less Lambda expression? a. Need to pass curly braces to denotes…
A: The above question is solved in step 2:-
Q: The mathematician Conway imagined a game, called game of life, which considered cells that are…
A: The mathematician Conway imagined a game, called game of life, whichconsidered cells that are…
Q: use python Implement the design of the Student and Lawyer class derived from Person class so that…
A: The Answer is
Q: The mathematician Conway imagined a game, called game of life, which considered cells that are…
A: Solution:-- 1)As the given question has required for the solution which is to be provided in the…
Q: In Java, specify, design, and implement a class called statistician. After a statistician is…
A:
Q: Create a program in java that implements Polymorphism to compute the wages of regular and…
A: Polymorphism is a property of implementing the method in various ways in various classes
Q: Program a class representing a player hand. The hand should be unbounded in size. A hand should have…
A: The program implementation is implemented below:
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: Write code in java to solve the following problems. Question 1: Most important Class in Customer…
A: The get method is used to obtain or retrieve a particular variable value from a class. A set value…
Q: write a c++(cpp) program that: Implement the class “cylinder” with member variables radius and…
A: Destructor deallocates the memory Constructor is invoked whenever the instance is created Copy…
Q: Java: Derive the class ExtClock from the class Clock by adding a data member to store the time zone.…
A: Inheritance is a feature of java object-oriented programming. The property of acquiring the parent…
Q: Write a program in java with the following feature: B. A class Book having data members BTitle,…
A: B) datamembers added with private label, of type string class Book { //B) datamembers BTitle,…
Q: In Java, implement abstract classes and interface in the grading system. Include three different…
A: Code: Grading.java: import java.util.Scanner;//abstract class having abstract methodspublic abstract…
Q: 3) Write a program in Java to define a class with 3 instance variables representing module name,…
A: Create a class Module. Declare the instance variables for module name, module marks and module…
Q: USING JAVA, specify, design, and implement a class called statistician. After a statistician is…
A:
Q: Q4. Apply the dynamic programming which studies in the class to make change for an amount N=10 using…
A: Introduction: Here we are required to Find the minimum number of coins to make change for the given…
Q: Solve the programming exercise P9.8 on Page 490 on the book. Implement a superclass Person. Make two…
A: // Screenshot of the code & output
Q: Write an abstract data type for rational numbers (a numerator and a denominator). Include a…
A: Since no programming language is mentioned, I am using c++. Code: #include <iostream>using…
Q: The following code segment is an example of public int min(int a, int b, int c) {. } public int…
A: When a method shows many forms then it is called as polymorphism. It has two types compile time and…
Q: Design and implement a simplified voting machine class with the following specification. A voting…
A: Program approach:- Import a package to get the standard I/O. Define the main function. Display the…
Q: Create the UML Class diagram for the following program and Implement the program in Java. Create a…
A: We are authorized to answer one question at a time since you have not mentioned which question you…
Q: Write an abstract data type for rational numbers (a numerator and a denominator). Include a…
A: the required code is as follows:-
Q: Write a java program using Encapsulation for the following class diagram. Get the values of name, id…
A: public class Name //replace name with your name { public static void main(String[]…
Q: Write a program that uses two classes. The first class is called “dAta" and holds x and y…
A: Summary: -Hence, we have discussed all the points.
Write a Java program to solve quadratic equations.
Design a class QuadraticRoots which has following members:
Data:
1.a
2.b
3.c
Methods:
Setter functions (total 3)
Getter functions (total 3)
computeRoots
> if the discriminant greater than zero --- find two distinct real roots
> if the discriminant equal to zero find the real roots
> if the discriminant is less than zero find the two distinct complex
(imaginary) roots
> should also handle the iota (i)
displayRoots
get values of a, b, c from the user and display the output for each case.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 4 images
- Design a class named LinearEquation for a 2-by-2 system of linear equations:ax + by = e x=(ed-bf)/(ad-bc)cx + dy = f y=(af-ec)/(ad-bc)The class contains:• Private double data fields a, b, c, d, e, and f.• A constructor with the arguments for a, b, c, d, e, and f.• Six getter methods for a, b, c, d, e, and f.• Methods getX() and getY() that return the solution for the equation.• A method named isSolvable() that returns true if ad - bc is not 0. The method isSolvable() willbe called in the main, if it returns true display the calculated values for x and y by calling getX()and getY(). If the call to isSolvable() returns false, display a message that “the equation has nosolution”.Write a test Java program that prompts the user to enter a, b, c, d, e, and f and displays the result. After the valuesfor a through f are entered, create a LinearEquation object. Check to seeIf ad - bc is 0, report that “The equation has no solution”, otherwise print out the values for x and y.Write a JAVA program Write a function inside ProblemSolution class whose return type is void, accepts an array and the length of the array as input parameters. The function should call a static method display of MyArray class by passing an array and length value. Input 5 1 5 8 2 0 Where, First line of input represents the size of an array. Second line represents array elements. Output 1 5 8 2 0 Assume that, N is an integer within the range [0 to 10000]. Array elements are integers within the range [-2147483648 to 2147483647].C++ Implement a Rational Number class with the following specifications. Data members a) numerator and denominator Functions a) Constructors: 1) default constructor 2) single parameter constructor to create numerator/1 3) dual parameter constructor to create numerator/denominator 4) Use constructor delegation across all constructors. b) Accessors and Mutators for both data members. c) Static recursive GCD function using Euclid’s algorithm. d) Static LCM function for two numbers. e) Reduce function simplify a rational number. This function modifies its calling object. f) Your program should work with the supplied driver program Notes LCM (Least Common Multiple) This function returns the smallest multiple of a and b. Step 1: Multiply a and b to find a common multiple. Step 2: Divide the common multiple by the GCD of a and b. Step 3: Return the result of Step 2. Reduce: This function reduces a fraction to simplest terms (i.e. 9/12 to 3/4). Step 1:…
- Write a JAVA program to model the kinds of people one finds in a university. The categories are students, teachers and teaching assistant (TAs). All these categories are kinds of Person (Person is abstract class. A teaching assistant (TA) is a student and a teacher as well. A person has a name (string). A student has grade point average GPA (between 0 to 4), the teacher has the number of scholarly papers he/she has published and the teacher assistant has the number of courses he/she assists. All the classes contain constructors with default arguments to fill all data spaces. Provide display method to print all data members of an object on the screen. Classes also contain a function called isSuccessful(). Students with a GPA over 3.5 are considered successful. This function returns true if someone is successful or false if not. In main(), define an array of Person class, which can point to students, teachers and teacher assistants. The program first asks the kind of person and then lets…Write a java program to create a class Employee which contains member variables as name (String object)empid (Integer object)salary (Float object)age (Integer object)Define a default as well as a parameterized constructor to initialize member variables with default and specified values respectively. Define and overload a method search as defined below boolean search (Employee e[ ], String name) To search an employee with name in an array of employee objects, if found return true, else false.boolean search (Employee e[ ], Integer empid) To search an employee with the empid in an array of employee objects, if found return true, else false.Also define another method to get the name of employee having highest salary in a set of employees. String getHighestSalary(Employee e[ ]) To return the name of the employee with highest salary in an array of employee objects.Input: At least 3 employee details like name, empid, salary and age.Name of employee to searchId of employee to searchOutput:…A java program, with a class Rectangle with attributes length and width , each of which defaults to 2. Providemethods that calculate the rectangle’s perimeter and area. It has set and get methods for bothlength and width . The set methods should verify that length and width are each floating-pointnumbers larger than 10.0 and less than 40.0. Write a program to test class Rectangle .
- Write a program in Java for the university consisting of the following categories: A mere Person classification contains the following variables:String name The person's name. 1int id id number. 2Write a constructor that receives the variables and a function (ID int , name String(add) whereYou receive the person's name and ID number and assign them. Write the Students class that inherits from the Person class containing the variablesnext:String Specialization The student's specialization. 1double gpa student average. 2Write a constructor that accepts the variables. (Two and a half degrees). Write the Employee class that inherits from the Person class containing the variablesnext:String jop The job name. 1int salary 2Write a constructor that accepts the variables. Create an interface for the program as shown in the following imageJava Question. I designed a function that is supposed to accept an int and return the int in reverse like so: Example 1: Input: x = 123 Output: 321 Example 2: Input: x = -123 Output: -321 Example 3: Input: x = 120 Output: 21 Example 4: Input: x = 0 Output: 0 My code appears to work for positive integers but returns an error when I enter a negative number. Any ideas how I can fix it? Thank you. import java.util.*; public class ReverseInteger{/**The Constructor sets @param var Description*/public static void main(String[] args){System.out.println("Please enter an integer: \n");Scanner keyboard = new Scanner(System.in);String input = keyboard.nextLine();int original = Integer.parseInt(input);int converted = reverse(original);System.out.println(converted);} public static int reverse(int x) // given in the problem set{ char[] chars = new char[String.valueOf(x).length()];String original1 = Integer.toString(x);boolean negative = false;int num_of_digits = 0;int reversed;for(int i = 0; i <…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)); }}
- Methods in Java Write a program that accepts three strings: first name, last name, age, and nationality. Create an object of the class Person and assign the inputs to their respective attributes. In the class, create a method greeting() that prints the attributes. Inputs 1. Input Cody Chum 20 Filipino Sample Output Enter first name: Cody Enter last name: Chum Enter age: 20 Enter nationality: Filipino Hello, I am Cody Chum, 20 years old and a Filipino!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 } }In Java: The program extends the representation for rational numbers Add a test class TestSimplifiedRational Define the simplified rationals r1..r4 and initialize them with 1/2, -3/9, 10/12 and 1 Compute sum=r1+r2 and diff=r4-r3 Simplify both results Check if they are equal, using equals and comparing their numerators and denominators. What do you observe? Compare r1 with r2, r3 and r4. Print all the rational numbers and partial results.