Initial commit

This commit is contained in:
2025-11-06 10:29:13 +08:00
commit 0becd14830
318 changed files with 7145 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
package Chapter3;
import java.util.Scanner;
public class SubwayTicket {
public static void main(String[] args) {
final String DESTINATION = "人民广场";
final double TICKET_PRICE = 2.00;
Scanner scanner = new Scanner(System.in);
System.out.println("购票信息");
System.out.println("--------------------");
System.out.println("目的车站: " + DESTINATION);
System.out.printf("票价: %.2f\n", TICKET_PRICE);
System.out.print("购票数量: ");
int numberOfTickets = scanner.nextInt();
double amountDue = numberOfTickets * TICKET_PRICE;
System.out.printf("应付金额: %.0f\n", amountDue);
System.out.print("已付金额: ");
int amountPaid = scanner.nextInt();
double change = amountPaid - amountDue;
System.out.printf("找零: %.0f\n", change);
scanner.close();
}
}