The program below is the answer to Liang’s Introduction to Java Programming (9th Edition) Chapter 2 Exercise 2.10.Question: Write a…
The program below is the answer to Liang’s Introduction to Java Programming (9th Edition) Chapter 2 Exercise 2.9.
1 2 |
/**<br /> *<br /> * @Author: Aghatise Osazuwa<br /> * Website: www.cscprogrammingtutorials.com<br /> *<br /> * Exercise 2.9 - Physics: Acceleration<br /> *<br /> */ <br /><br />import java.util.Scanner;<br /><br />public class PhysicsAcceleration {<br /> public static void main (String [] args) {<br /><br /> Scanner input = new Scanner(System.in);<br /> <br /> System.out.println("This Program Calculates Average Acceleration.n");<br /> <br /> System.out.println("Enter starting velocity(v0) in meter/second: ");<br /> double startingVelocity = input.nextDouble();<br /> <br /> System.out.println("Enter ending velocity(v1) in meter/second: ");<br /> double endingVelocity = input.nextDouble();<br /> <br /> System.out.println("Enter time(t) in seconds: ");<br /> double time = input.nextDouble();<br /> <br /> double average = (endingVelocity - startingVelocity) / time;<br /> <br /> //display result to 4 decimal places<br /> System.out.println("The average acceleration is " + (int)(average * 10000) / 10000.0);<br /> }<br />}<br /> |
Click here to…
The program below is the answer to Liang’s Introduction to Java Programming (9th Edition) Chapter 2 Exercise 2.8.Question: (Current time)…
The program below is the answer to Liang’s Introduction to Java Programming (9th Edition) Chapter 2 Exercise 2.7.Question: (Find the…
The program below is the answer to Liang’s Introduction to Java Programming (9th Edition) Chapter 2 Exercise 2.6.Question: Write a program…
The program below is the answer to Liang’s Introduction to Java Programming (9th Edition) Chapter 2 Exercise 2.5.
1 2 |
/**<br /> *<br /> * @Author: Aghatise Osazuwa<br /> * Website: www.cscprogrammingtutorials.com<br /> *<br /> * Exercise 2.5 - Financial Application: Calculate Tips<br /> *<br /> */ <br /><br />import java.util.Scanner;<br /><br />public class FinancialApplication {<br /> public static void main (String [] args) {<br /> Scanner input = new Scanner(System.in);<br /> System.out.println("This Program Computes Gratuity.n");<br /> System.out.println("Enter the subtotal and a gratuity rate: ");<br /> double subtotal = input.nextDouble();<br /> double gratuityRate = input.nextDouble();<br /> double gratuity = gratuityRate/10;<br /> double total = subtotal + gratuity;<br /> <br /> System.out.printf ("The gratuity is $" + gratuity + " and total is $" + total + "n");<br /> }<br />}<br /> |
Click here to…
The program below is the answer to Liang’s Introduction to Java Programming (9th Edition) Chapter 2 Exercise 2.4.
1 2 |
/**<br /> *<br /> * @Author: Aghatise Osazuwa<br /> * Website: www.cscprogrammingtutorials.com<br /> *<br /> * Exercise 2.4 - Convert Pounds To Kilograms<br /> *<br /> */ <br /><br />import java.util.Scanner;<br /><br />public class ConvertPoundsToKilograms {<br /> public static void main (String [] args) {<br /> Scanner input = new Scanner(System.in);<br /> System.out.println("This Program Converts A Number In Pounds To Kilograms.n");<br /> System.out.println("Enter a number in pounds: ");<br /> double pounds = input.nextDouble();<br /> double kilograms = pounds * 0.454;<br /> <br /> System.out.printf (pounds + " pounds is " + kilograms + " kilograms.n");<br /> }<br />} |
Click here to…
The program below is the answer to Liang’s Introduction to Java Programming (9th Edition) Chapter 2 Exercise 2.3.
1 2 |
/**<br /> *<br /> * @Author: Aghatise Osazuwa<br /> * Website: www.cscprogrammingtutorials.com<br /> *<br /> * Exercise 2.3 - Convert Feet To Meters<br /> *<br /> */ <br /><br />import java.util.Scanner;<br /><br />public class FeetToMeters {<br /> public static void main (String [] args) {<br /> Scanner input = new Scanner(System.in);<br /> System.out.println("This Program Converts A Number In Feet To Meters.n");<br /> System.out.println("Enter a value for feet: ");<br /> double feet = input.nextDouble();<br /> double meters = feet * 0.305;<br /> System.out.printf (feet + " feet is " + meters + " meters.n");<br /> }<br />} |
Click here to…
The program below is the answer to Liang’s Introduction to Java Programming (9th Edition) Chapter 2 Exercise 2.2.
1 2 |
/**<br /> *<br /> * @Author: Aghatise Osazuwa<br /> * Website: www.cscprogrammingtutorials.com<br /> *<br /> * Exercise 2.2 - Compute The Volume Of A Cylinder<br /> *<br /> */ <br /><br />import java.util.Scanner;<br /><br />public class VolumeOfCylinder {<br /> public static void main (String [] args) {<br /> Scanner input = new Scanner(System.in);<br /> System.out.println("This Program Computes The Area And Volume Of A Cylinder.n");<br /> System.out.println("Enter the radius and length of a cylinder separated "<br /> + "by a space or by pressing the ENTER key: ");<br /> double radius = input.nextDouble();<br /> double length = input.nextDouble();<br /> double area = radius * radius * Math.PI;<br /> double volume = area * length;<br /> <br /> System.out.printf ("%s%.2f%s%.2f%s", "The Area is ", area, <br /> "nThe Volume is ", volume, "n");<br /> }<br />}<br /> |
Click here to…
The program below is the answer to Liang’s Introduction to Java Programming (9th Edition) Chapter 2 Exercise 2.1.
1 2 |
/**<br /> *<br /> * @Author: Aghatise Osazuwa<br /> * Website: www.cscprogrammingtutorials.com<br /> *<br /> * Exercise 2.1 - Convert Celsius To Fahrenheit<br /> *<br /> */ <br /><br />import java.util.Scanner;<br /><br />public class ConvertCelsiusToFahrenheit {<br /> public static void main (String [] args) {<br /> Scanner input = new Scanner(System.in);<br /> System.out.println("This Program Converts Degrees From Celcius To Fahrenheit.n");<br /> System.out.print("Enter Celcius Degree: ");<br /> double celcius = input.nextDouble();<br /> double fahrenheit = (9.0/5) * celcius + 32;<br /> System.out.println (celcius + " Celcius is " + fahrenheit + " Fahrenheit.");<br /> }<br />}<br /><br /> |
Click here to…
1 2 |
/**<br /> *<br /> * @Author: Aghatise Osazuwa<br /> * Website: www.cscprogrammingtutorials.com<br /> *<br /> * Exercise 1.12 - Average Speed In Kilometers<br /> *<br /> */ <br /><br />public class Ex1_12 {<br /> public static void main(String[] args) {<br /> System.out.println("Distance = 24 miles =" + (24.0 * 1.6) + " kilometersn");<br /> System.out.println("Time = 1 hour 40 minutes 35 seconds" + " = "<br /> + (1 + (((40.0 * 60.0) + 35.0) / 3600)) + " hours.n");<br /> System.out.print("Average Speed In kilometers per hour = ");<br /> System.out.println(((24.0 * 1.6) / (1 + (((40.0 * 60.0) + 35.0) / 3600)))<br /> + " kph.");<br /> }<br />} |
Program OutputClick here to see other solutions to Introduction to Java Programming.
1 2 |
/**<br /> *<br /> * @Author: Aghatise Osazuwa<br /> * Website: www.cscprogrammingtutorials.com<br /> *<br /> * Exercise 1.10 - Average Speed In Miles<br /> *<br /> */ <br /><br />public class Ex1_10 {<br /> public static void main(String[] args) {<br /> System.out.println("Distance = 14km nTime = 45 minutes 30 seconds = (45 x 60) + 30 n"<br /> + " -------------- hours n"<br /> + " 3600 n"<br /> + "1 mile = 1.6 kilometers. nAverage Speed in miles per hour = "<br /> + (14.0 / 1.6)/ (((45.0 * 60.0) + 30.0) / 3600) + " mph.");<br /> }<br />} |
Program OutputClick here to see other solutions to Introduction to Java Programming.