Gratuity

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Gratuity as PDF for free.

More details

  • Words: 233
  • Pages: 2
Gratuity /* * Filename: Gratuity.java * Created by 1,000_naymes * Purpose: to compute a gratuity and total when a user enters their subtotal & gratuity rate */ import javax.swing.JOptionPane; public class Gratuity { public static void main( String[] args ) { /************************************************************** declare and initialize variables **************************************************************/ String openingMessage, subtotalInputMessage, rateInputMessage, subtotalString, rateString, outputMessage; double subtotal, rate, properRate, gratuity, total; /************************************************************** display opening message ******************************************y********************/ openingMessage = "Welcome to 1KN's gratuity program, which will calculate your gratuity and total.\n"; JOptionPane.showMessageDialog( null, openingMessage ); /************************************************************** input **************************************************************/ subtotalInputMessage = "Please enter the subtotal for your meal: $"; subtotalString = JOptionPane.showInputDialog( subtotalInputMessage ); subtotal = Double.parseDouble( subtotalString ); //converting string to double rateInputMessage = "Please enter your gratuity rate as an integer (do not include %, \nfor example 5.25 or 6): "; rateString = JOptionPane.showInputDialog( rateInputMessage); rate = Double.parseDouble( rateString ); //converting string to double properRate = rate / 100; /************************************************************** processing **************************************************************/ // calculating the gratuity gratuity = properRate * subtotal; // calculating the total total = subtotal + gratuity; /************************************************************** output **************************************************************/ outputMessage = "You entered a subtotal of $" + subtotal + "\n and a gratuity rate of " + rate + "%. " + "\n The gratuity for your meal is $" + gratuity + "\n and your total is $" + total + "."; Page 1

Gratuity JOptionPane.showMessageDialog( null, outputMessage ); System.exit(0); } //end main } //end class

Page 2

Related Documents

Gratuity
November 2019 8
Gratuity Act
October 2019 15
Pention And Gratuity
June 2020 2
Revised Pension & Gratuity
November 2019 4
Payment Of Gratuity Act
December 2019 13