Below is a java program to find roots of quadratic equation. Please explain each line of code if what it does in the program when executed. Example: Java Program to Find Roots of a Quadratic Equation public class Main { public static void main(String[] args) {
Q: Have a research on the use of the Math methods and write a program that uses Math method. Use at…
A: Solution: 1) Java code: public class Main { public static void main(String[]…
Q: 3. Write Java program that will calculate the amount to be paid for electrical consurmption This…
A: Objective: This program would compute the electricity bill amount in which the consumer can opt for…
Q: Write a code Java in Example shown in the picture
A: Given that write. A Java code in example shown in the diagram. Composition I know that composition…
Q: Can we execute a program without main() method? In java
A: Required: Question 31: Can we execute a program without main() method? In java
Q: Note: The below Java program consists of multiple source files. Click on the "CallPerson.java" or…
A: The output is, You are Ann Wayne I am Bob Rogers Observe the below screenshot
Q: 9. Consider the method headings: void funcOne(int [] alpha, int size) int funcSum(int x, int y) void…
A: In Java static methods are called normally but the methods which are not static are called through…
Q: In this java program, please explain the output.
A: Explaination for the output is given below
Q: What is the number of operations executed when the following Java code runs? Your answer is expected…
A: The given code is below- public class RandomSequence { public static void main ( String[] args ) {…
Q: public class array { public static void main(String args[] {…
A: ArrayIndexOutOfBoundsException
Q: Write a Java program that does the following: Write a Java program that does the following: 1. In…
A: The program for the above-given question is given below.
Q: Write a recursive Java method that calculates the sum of n positive integer numbers. The math…
A: Note:- please mention type of error which you have faced in your post. Here is logic:- public…
Q: Write the Java program: Make sure to have proper code indentation. Code: class Main { public…
A: class Tile{ char letter; int value; //Constructor Tile(char l, int v) {…
Q: 4. Consider the following program segment: public class Ch7_PrExercise4 public static void main…
A: we can only solve one question in one post. solving first. please post second question saperatly.…
Q: 1. Write a Java program that will ask the a user a number between 1 to 7. 2. Print out the…
A: PROGRAM STRUCTURE: Import the required packages. Start the definition of the man public class.…
Q: Evaluate the JAVA code snippet below, then motivate why this is representative of good programming…
A: Good programming practices: The given code snippet is not an example of good programming practice…
Q: Solution IN JAVA A quadratic equation a x² + b x + c = 0 has either 0, 1, or 2 distinct solutions…
A: In this problem we need to provide the solution in the JAVA Programming language. Algorithm -…
Q: In Java Design and implement a program that implements the following 3 methods: - Method…
A: In this question, we have to write a Java program for the area of rectangle and parameter of…
Q: What is the number of operations executed when the following Java code runs? Your answer is expected…
A: public class AddThree { public static void main(String[] args) { Stdout.print("Type the first…
Q: What will be the output of the following Java program? class dynamic_initialization public static…
A: initially a=3.0 b=4.0
Q: Show the output of the following programs. (Hint: Draw a table and list the variables in the columns…
A: Given: Show the output of the following programs. (Hint: Draw a table and list the variables in the…
Q: What is the number of operations executed when the following Java code runs? Your answer is expected…
A: The given code is below- public class RandomSequence { public static void main ( String[] args ) {…
Q: What will be the output of the following Java program? class output public static void main(String…
A: Given, Code: class Output { public static void main(String args[]) { int arr[]…
Q: Overriding static and private methods is allowed in Java. Consider the following statement.
A: Introduction: Method concealing is the term for the situation described here, and overriding is not…
Q: 4) For the following problem, write a program (in as close to Java code -but doesn’t need to be…
A: Pseudocode: function play: ans= max element in array // if array contanis atleast one equal ajacent…
Q: Need dry run for the following code in java language This question is from the book absolute…
A: For this question, there is supposed to be 2 classes, Circle and Rectangle where there will be a…
Q: .What will be the output when the following program is executed? public class Recur{ public…
A: using the function the code is called directly and indirectly which is called the recursive function…
Q: Give an example of declaration statement and an example of an assignment statement that will be used…
A: I have designed a JAVA PROGRAM that converts Celsius to Fahrenheit and Fahrenheit to Celsius.…
Q: 3. A program that prints the power table for integers from 1 to 5. The table must include the…
A: public class Main{ public static void main(String[] args) { System.out.print("\t\t\t\t\tPower…
Q: You were hired by PAGCOR as part of the programming team in-charge of automating its BINGO game.…
A: Lets see the solution.
Q: public class FindTheError { public int square(int number) { return number *…
A: Hi. Let's move on to the solutions in next step.
Q: 1) Convert the following Java code by using a function in C++, Python. public class lab9{ public…
A: Code in Java: public class lab9{ public static void main(String[] args) { System.out.println("10 +…
Q: Write a Java program that will call a method (called f) to caluculate the following function. f(x)…
A: Given:- Write a Java program that will call a method (called f) to calculate the following function.…
Q: class Main { | public static void main(String[1 arc
A: Answer:
Q: Write java program that will calculate the amount to be paid for electrical consumption. This…
A: Objective: This program would determine the bill amount or electricity consumption for customers.…
Q: he following program takes two numbers as input from the user when run and is supposed to add those…
A: Consider the given code: public class Example { public static void main(String[] args) { int…
Q: Solution IN JAVA A quadratic equation a x² + b x + c = 0 has either 0, 1, or 2 distinct solutions…
A: In this problem, we will solve in the Java Programing language. Input - three integer as argument…
Q: plz help with the following: IN JAVA Why does the following method have a compile error
A: throw keyword is used to throw an exception. new creates a new exception. Exception message can be…
Q: The following code is in Java,find the error in the following: int[] table = new int[10]; for…
A: Given the code is in the java we have to find the error in the Following:
Q: // Example.java: class Example { public static void exampleFun() Rectangle s- new Rectangle(5,7);…
A: Option B) in Example.java instead of : ss.length = 10;it should be ss.setLength(10);
Q: Show the derivation of the asymptotic run time, O(n), for each of the following methods. You may…
A: The question is to find the asymptotic time complexity of the given java code.
Q: ((Java)) Create two Java methods. the very first: that accepts a value and determines whether or…
A: Given :- Create two Java methods. the very first: that accepts a value and determines whether or…
Q: What will be the output of the following Java code? class average { public static…
A: Question. What will be the output of the following Java code? class average {…
Q: use java Declare a method and complete the following operations. a. Method name is Add b. It…
A: Find Your Answer Below
Q: Why the given Java code is not getting compiled and giving error? Remove the errors as well. class…
A: There are two errors in the given code: The first error is the wrong initialization of the array.…
Q: PROBLEM STATEMENT: Add two numbers together and return the resulting sum. public class…
A: To write java program to add two numbers together and return the sum.
Q: The following program is designed to find the area of a rectangle, the area of a circle, or the…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: What is the output of the following Java code? public class array { public static void main(String…
A: Refer to step 2 for the answer.
Q: Below is a java program to find roots of quadratic equation. Please explain each line of code if…
A: Code in Java: NOTE: out.format() method must be from System class so write it as…
Below is a java
Example: Java Program to Find Roots of a Quadratic Equation
- public class Main {
- public static void main(String[] args) {
- double a = 2.3, b = 4, c = 5.6;
- double root1, root2;
- double determinant = b * b - 4 * a * c;
- if (determinant > 0) {
- root1 = (-b + Math.sqrt(determinant)) / (2 * a);
- root2 = (-b - Math.sqrt(determinant)) / (2 * a);
- out.format("root1 = %.2f and root2 = %.2f", root1, root2);
- }
- else if (determinant == 0) {
- root1 = root2 = -b / (2 * a);
- out.format("root1 = root2 = %.2f;", root1);
- }
- else {
- double real = -b / (2 * a);
- double imaginary = Math.sqrt(-determinant) / (2 * a);
- out.format("root1 = %.2f+%.2fi", real, imaginary);
- out.format("\nroot2 = %.2f-%.2fi", real, imaginary);
- }
- }
- }
Step by step
Solved in 5 steps with 2 images
- class main { public static void main(String args[]) { int x =2; int y =0; for(; y <10;++y) { if(y % x ==0) continue; elseif(y ==8) break; else System.out.print(y +" "); } } } Give result for the code Java Try to do ASAPlight } What is the output of this Java program? } class Driver { public static void main(String[] args) { int a = 6: int b = 6; int c = 5; int x = 1; if (a > 2) { } } if x = x + 600; (b> 3) { x = x + 60; } if (c < 9) { X = x + 5; System.out.print(x);PROBLEM STATEMENT: An anagram is a word that has been rearranged from another word, check tosee if the second word is a rearrangement of the first word. public class AnagramComputation{public static boolean solution(String word1, String word2){// ↓↓↓↓ your code goes here ↓↓↓↓return true;}} Can you help me with this java question the language is java please use the code I gave
- Exercise 1 - What is wrong in the code below: public class Main { public static void main(String[] args) { int x = 5 int y = 10; int z = x + y; System.out.println(z); }} Exercise 2 - What is wrong in the code below: public class Main { public static void main(String[] args) { int x = 5; int y = 0; int z = x / y; System.out.println(z); }} Exercise 3 - What is wrong in the code below: public class Main { public static void main(String[] args) { int x = 5; int y = 10; int z = x - y; System.out.println("The difference between " + x + " and " + y + " is " + z); }} Exercise 4 - What is wrong in the code below: public class Main { public static void main(String[] args) { int 1stNumber = 5; int second_number = 10; int sum = 1stNumber + second_number; System.out.println(sum); }} Exercise 5 - What is wrong in the code below: public class Main { public static…class class { public static void main(String args[]) { int a =5; int b =10; first: { second: { third: { if(a == b >>1) break second; } System.out.println(a); } System.out.println(b); } } } Give result for the code Java Try to do ASAP#include void main () { int a=5,b=10,c=1; if (a && b>c) { printf("cquestionbank"); } else{ break; } }
- Explain this java codes private void put(int cell,int player) { int i=-1,j=-1;; switch(cell) { case 1:i=2;j=0;break; case 2:i=2;j=1;break; case 3:i=2;j=2;break; case 4:i=1;j=0;break; case 5:i=1;j=1;break; case 6:i=1;j=2;break; case 7:i=0;j=0;break; case 8:i=0;j=1;break; case 9:i=0;j=2;break; default:display(overridegrid);return; } char mark='x'; if(player==0) mark='o'; grid[i][j]=mark; display(grid); } private int startGame() { init(); display(grid); int status=playingid; while(status==playingid) { put(playerMove(),0); if(override==1) { System.out.println("O wins."); return playerid; } status=checkForWin(); if(status!=playingid) break; try{Thread.sleep(1000);}catch(Exception e){System.out.print(e.getMessage());} put(compMove(),1); status=checkForWin(); } return status; } private void init() { movesPlayer=""; override=0; marks=new int[8][6]; wins=new int[][] //new int[8][3]; weights=new int[]{3,2,3,2,4,2,3,2,3}; grid=new…NEED HELP WITH JAVA PROGRAM ERROR PLEASE HELP THANK YOU CODE: class quad{public static void main(String args[] ){Quadrilateral quadrilateral = new Quadrilateral( 1.1, 1.2, 6.6, 2.8, 6.2, 9.9, 2.2, 7.4 );Trapezoid trapezoid = new Trapezoid (0.0, 0.0, 10.0, 0.0, 8.0, 5.0, 3.3, 5.0 );Parallelogram parallelogram = new Parallelogram (5.0, 5.0, 11.0, 5.0, 12.0, 20.0, 6.0, 20.0 );Rectagle rectagle = new Rectagle(17.0, 14.0, 30.0, 14.0, 30.0, 28.0, 17.0, 28.0 );Square square = new Square( 4.0, 0.0, 8.0, 0.0, 8.0, 4.0, 4.0, 4.0 );System.out.printf("%s %s %s %s %s\n", quadrilateral, trapezoid, parallelogram, rectagle, square );}}class Point{private double x;private double y;public Point(double xCoordinate, double yCoordinate){x = xCoordinate;y = yCoordinate;}public double getX(){return x;}public double getY(){return y;}public String toString(){return String.format( "( %.1f, %.1f)", getX(), getY() );}}class Quadrilateral {private Point point1;private Point point2;private Point point3;private…Exercise Arithmetic (Command-line arguments): Write a program called Arithmetic that takes three command-line arguments: two integers followed by an arithmetic operator (+, -, * or /). The program shall perform the corresponding operation on the two integers and print the result. For example: java Arithmetic 3 2 + 3+2=5 java Arithmetic 3 2 - 3-2=1 java Arithmetic 3 2 / 3/2=1 Hints: The method main(String[] args) takes an argument: "an array of String", which is often (but not necessary) named args. This parameter captures the command-line arguments supplied by the user when the program is invoked. For example, if a user invokes: java Arithmetic 12345 4567 + The three command-line arguments "12345", "4567" and "+" will be captured in a String array {"12345", "4567", "+"} and passed into the main() method as the argument args. That is, args is: {"12345", "4567", "+"} // args is a String array args.length is: 3 // length of the array args[0] is: "12345"…
- using System;class Program{ public static void Main(string[] args) { int number = 1; while (number <= 1000) { Console.WriteLine(number); number = number + 1; } }} how can this code be fixed to count from 1-20 and then 50-70 and then from 800-1000?3).class jump_statments { public static void main(String args[1) { int x = 2; int y = 0; for (; y < 10; ++y) { if (y % x 0) == continu e; else if (y 8) break; == else %3D System.out.print(y + " "); } a) 1357 b) 24 68 c) 1 3579 d) 1234 5 6 7 8 9using System;class Program{ public static void Main(string[] args) { int number = 1; while (number <= 1000) { Console.WriteLine(number); number = number + 1; } }} how would i add an if statement to this code? any if statement would work