Answered step by step
Verified Expert Solution
Question
1 Approved Answer
There are 3 types of train tickets: - yellow zone y-ticket: $10 each - blue zone b-ticket: $15 each - red zone r-ticket: $30
There are 3 types of train tickets: - yellow zone y-ticket: $10 each - blue zone b-ticket: $15 each - red zone r-ticket: $30 each Write a function to display the cost of train ticket like the following examples. Note that you only need to put the code of the function in the answer box and nothing else (do NOT put other code of the class in the answer box). For example: Test ticketCost (5, 1, 2); Result The ticket cost is y-tickets: 5 x $10 = $50 b-tickets: 1 x $15 = $15 r-tickets: 2 x $30 = $60 Total: $50 + $15 + $60 = $125 ticketCost(0, 10, 1); The ticket cost is y-tickets: 0 x $10 = $0 b-tickets: 10 x $15 = $150 r-tickets: 1 x $30 = $30 Total: $0 + $150 + $30 = $180 2 3 System.out.println("The ticket cost is ")%;B 4 System.out.println("y-tickets : + yTicket + x $10 = " 5 System.out.println("b-tickets : + bTicket + x $15 = 6 System.out.println("r-tickets : + rTicket + x $30 = 7 System.out.println("Total: $" + costofYTickets + " Answer: (penalty regime: 0 %) Reset answer 1 public static void ticketCost(int yTicket, int bTicket, int rTicket) { int totalCost = costofYTickets + costOfBTickets + costOfRTickets; " " + costofYTickets); + costOfBTickets); + costOfRTickets); " " + $ + costOfBTickets + +$" + costOfRTickets + = $' + total Cost); 8 9 10
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started