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 see other solutions to Introduction to Java Programming.