(财务应用程序:计算小费)编写一个程序,读入一笔费用与酬金率,计算酬金和总钱数。例如,如果用户输人10 作为费用,15% 作为酬金率,计算结果显示酬金为 $1.5, 总费用为$11.5。
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package dome2_5;
import java.util.Scanner;
/**
*
* @author Administrator
*/
public class Dome2_5 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner in = new Scanner(System.in);
System.out.print("Enter the subtotal and a gratuity rate:");
double subtotal = in.nextDouble();
double gratuityrate = in.nextDouble();
double gratuity = subtotal * gratuityrate / 100;
System.out.println("The gratuity is $" + gratuity + " and total is $" + (subtotal+gratuity));
}
}