Enter the subtotal and gratuity rate: 10 12 The gratuity is $1.2 and total is $11.2
package gratuity;
import java.util.Scanner;
public class Gratuity {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter the subtotal and gratuity rate: ");
float subtotal = scan.nextFloat();
double rate = scan.nextDouble();
rate = 0.01 * rate;
System.out.printf("The gratuity is $%f and total is $ %f", (rate * subtotal), ((rate * subtotal)+ subtotal));
}
}
Comments
Leave a comment