Java语言程序设计基础篇编程练习题2.5示例代码

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_38234015/article/details/88315933
import java.util.Scanner;

public class Test2_05 {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		System.out.print("Enter the subtotal and a gratuity rate:");
		double subtotal = input.nextDouble();
		double rate = input.nextDouble();
		input.close();
		double gratuity = rate / 100 * subtotal; 
		System.out.println("The gratuity is $" + gratuity + " and total is $" + (gratuity + subtotal));
	}
}

猜你喜欢

转载自blog.csdn.net/qq_38234015/article/details/88315933