Over the years, our phones have become an important part of our lives. We can barely do without them. We…
The program below is the solution to Liang’s Introduction to Java Programming (9th Edition) Chapter 3 Exercise 3.2.Question: The program…
Businesses and individuals can barely do without technology in their daily lives. In fact, some believe that with technology everything…
Cyberattack is prevalent now because many of our activities have moved online. For example, last week, there was a major…
There are plenty of articles out there about how to prepare for a computer certification exam. However, there are also…
The program below is the answer to Liang’s Introduction to Java Programming (9th Edition) Chapter 3 Exercise 3.1.
1 2 |
/**<br /> *<br /> * @Author: Aghatise Osazuwa<br /> * Website: www.cscprogrammingtutorials.com<br /> * Exercise 3.1 - Algebra: Solve Quadratic Equations<br /> */<br />import java.util.Scanner;<br /><br />public class CheckerboardPatternOfAsterisks {<br /> public static void main (String [] args) {<br /> <br /> // declare variables<br /> double a, b, c, disc, r1, r2;<br /> <br /> // create Scanner to read user input<br /> Scanner input = new Scanner(System.in);<br /><br /> // prompt user to enter details<br /> System.out.print("Enter a, b, c: ");<br /> a = input.nextDouble();<br /> b = input.nextDouble();<br /> c = input.nextDouble();<br /><br /> //calculate the discriminant<br /> disc = b * b - (4 * a * c);<br /> <br /> //calculate the roots<br /> r1 = (-b + Math.pow(disc, 0.5)) / (2 * a);<br /> r2 = (-b - Math.pow(disc, 0.5)) / (2 * a);<br /><br /> // display the results<br /> if (disc > 0){<br /> System.out.println("The roots are " + r1 + " and " + r2 + "n");<br /> }<br /> <br /> if (disc == 0){<br /> System.out.println("The root is " + r1 + "n");<br /> }<br /> <br /> if (disc < 0){<br /> System.out.println("The equation has no real roots.n");<br /> }<br /> }<br />}<br /> |
Sample Program runClick…
A DIMM, or dual in-line memory module, is a double component of the single in-line memory module. In actual structure,…
About 1.4 billion people have and use Smartphones daily, but how many of them actually maximize its functions? Aside from…
Since the internet trend started in the 1990s, many governments and business activities, and state secrets have moved from offline…
It is very important to take the protection against online information larceny, because it’s getting very easy for people to…
Your activities online can make your smartphone prone to virus. You download free apps, movies, and songs online as well…
Verizon Communications may seek to renegotiate its $4.8 billion purchase of Yahoo’s operating business, dealing another blow to the struggling…