200字
2026-09-23 课堂任务与课后作业
2026-09-23
2026-09-23

程序运行网站:

https://www.jyshare.com/compile/10/

课堂任务:

Your task is to practice nested if statements.Write a Java program named MovieTicket that completes the following tasks in the main method:

Step 1: Create a double variable price with the value 50.0 (price per ticket); Create a boolean variable isMember with the value true (whether the viewer is a member); Create an int variable quantity with the value 3 (number of tickets purchased).

Step 2: Use nested if statements to calculate the discount based on whether the viewer is a member and the quantity purchased, according to the following rules: If the viewer is a member:If quantity >= 3, apply a 20% discount (multiply by 0.8);Otherwise, apply a 10% discount (multiply by 0.9) If the viewer is not a member:If quantity >= 3, apply a 5% discount (multiply by 0.95);Otherwise, no discount

Step 3: Calculate the total price = price per ticket × quantity

Step 4: Output in the following format:

请提交代码截图至问卷星https://v.wjx.cn/vm/Q4MTlhE.aspx#

2026-09-23 课堂任务与课后作业
作者
Administrator
发表于
2026-09-23
License
CC BY-NC-SA 4.0