The program below is the answer to Liang’s Introduction to Java Programming (9th Edition) Chapter 2 Exercise 2.14.Question: Health application:…
The program below is the answer to Liang’s Introduction to Java Programming (9th Edition) Chapter 2 Exercise 2.13.
1 2 |
/**<br /> *<br /> * @Author: Aghatise Osazuwa<br /> * Website: www.cscprogrammingtutorials.com<br /> *<br /> * Exercise 2.13 - Financial Application: Compound Value<br /> *<br /> */ <br /><br />import java.util.Scanner;<br /><br />public class CompoundValue {<br /><br /> public static void main(String[] args) {<br /> <br /> //Display Program Information<br /> System.out.println("This Program Calculates The Compound Value Of An "<br /> + "Account After The Sixth Month.n");<br /><br /> //create Scanner <br /> Scanner input = new Scanner(System.in);<br /><br /> //prompt user to enter details<br /> System.out.println("Enter the monthly saving amount:");<br /> double savings = input.nextDouble();<br /><br /> //calculate the account value after the sixth month<br /> double firstMonth = savings * (1 + 0.00417);<br /> double secondMonth = (savings + firstMonth) * (1 + 0.00417);<br /> double thirdMonth = (savings + secondMonth) * (1 + 0.00417);<br /> double fourthMonth = (savings + thirdMonth) * (1 + 0.00417);<br /> double fifthMonth = (savings + fourthMonth) * (1 + 0.00417);<br /> double sixthMonth = (savings + fifthMonth) * (1 + 0.00417);<br /><br /> //format the sixth month to two decimal places<br /> sixthMonth = (int) (sixthMonth * 100) / 100.0;<br /><br /> //display the result<br /> System.out.println("After the sixth month, the account value is $"<br /> + sixthMonth + "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.12.
1 2 |
/**<br /> *<br /> * @Author: Aghatise Osazuwa<br /> * Website: www.cscprogrammingtutorials.com<br /> *<br /> * Exercise 2.12 - Physics: Finding Runway Length<br /> *<br /> */ <br /><br />import java.util.Scanner;<br /><br />public class RunwayLength {<br /><br /> public static void main(String[] args) {<br /> <br /> //Display Program Information<br /> System.out.println("This Program Calculates The Minimum Runway Length "<br /> + "Needed For An Airplane To Take Off.n");<br /><br /> //create Scanner <br /> Scanner input = new Scanner(System.in);<br /><br /> //prompt user to enter details<br /> System.out.println("Enter speed (in meters per second) and "<br /> + "acceleration (in meters/second squared):");<br /> double speed = input.nextDouble();<br /> double acceleration = input.nextDouble();<br /><br /> //calculate length <br /> double length = ((speed * speed) / (2 * acceleration));<br /> <br /> //format length to 4 decimal places<br /> length = (int)(length * 10000) / 10000.0;<br /><br /> //display the result<br /> System.out.println("The minimum runway length for this airplane is "<br /> + length + "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.11.Question: Rewrite Exercise…
The program below is the answer to Liang’s Introduction to Java Programming (9th Edition) Chapter 1 Exercise 1.11.
1 2 |
/**<br /> *<br /> * @Author: Aghatise Osazuwa<br /> * Website: www.cscprogrammingtutorials.com<br /> *<br /> * Exercise 1.11 - Population Projection<br /> *<br /> */ <br /><br />import java.util.Scanner;<br /><br />public class PopulationProjection {<br /><br /> public static void main(String[] args) {<br /> <br /> int birth = 7;<br /> int death = 13;<br /> int immigrant = 45;<br /> int currentPopulation = 312032486;<br /> int year = 365;<br /> int yearlyBirths = (((60 * 60 * 24 * year) / birth));<br /> int yearlyDeaths = (((60 * 60 * 24 * year) / death));<br /> int yearlyImmigrants = (((60 * 60 * 24 * year) / immigrant));<br /> int yearlyPopulation = (yearlyBirths + yearlyImmigrants - yearlyDeaths);<br /><br /> System.out.println("Current Year Population = " + currentPopulation);<br /> System.out.println("Next Year's Population = "<br /> + (currentPopulation + yearlyPopulation));<br /> System.out.println("Next Two Year's Population = "<br /> + (currentPopulation + (yearlyPopulation * 2)));<br /> System.out.println("Next Three Year's Population = "<br /> + (currentPopulation + (yearlyPopulation * 3)));<br /> System.out.println("Next Four Year's Population = "<br /> + (currentPopulation + (yearlyPopulation * 4)));<br /> System.out.println("Next Five Year'ss Population = "<br /> + (currentPopulation + (yearlyPopulation * 5)));<br /> }<br />}<br /> |
Click here to…