package hello; import java.util.Scanner; public class Main { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub // double a = 1.0; // double b = 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1; // System.out.println("a=" + a + ";b=" + b); // System.out.println(a == b); // System.out.println(Math.abs(a - b) < 1e-6); // 初始化 Scanner in = new Scanner(System.in); int balance=0; while (true) { // 请输入投币金额 System.out.print("请投币: "); int amount = in.nextInt(); balance=balance+amount; // System.out.println(amount); // System.out.println(amount >= 10); if (balance >= 10) { // 打印车票 // System.out.println("echo:"+in.nextLine()); System.out.println("*****************"); System.out.println("* 京津冀城际铁路专线 *"); System.out.println("* 无指定座位票 *"); System.out.println("* 票价10元 *"); System.out.println("*****************"); // 打印输出找零 System.out.println("找零:" + (balance - 10)); balance=0; } // else // { // balance=balance+amount; // } } } }
时间: 2024-10-12 16:37:43