java - How do i get the other text from not displaying- decision structures? -
i have been trying find solution i'm not getting it. when input age 13
, time 2230
both "midnight madness not available children under 14 years old!" , price output.
in console:
please enter age: [13]
please enter show time: [2230]
midnight madness not available children under 14 years old!the ticket price $8.00>
import java.util.scanner; import java.text.decimalformat; public class movietickets { public static void main(string[] args) { scanner input = new scanner(system.in); decimalformat df = new decimalformat("$#.00"); int age; int time; double price = 8.00; double ch = 4.00; system.out.print("please enter age:"); age = input.nextint(); system.out.print("please enter show time: "); time = input.nextint(); system.out.print(" "); if (age > 13) if (time < 1800) price = 5.00; else if (time > 2200) price = 4.00; if (age < 14) { if (time < 1800) price = 2.00; else if (time > 2200) system.out.print("midnight madness not available children under 14 years old!"); else price = 4.00; } system.out.print("the ticket price " + df.format(price)); } }
Comments
Post a Comment