Question: Bellow is what I've written so far... I ' m having a hard time getting it to print out usingThe answer is: + myAnswer.

Bellow is what I've written so far... I'm having a hard time getting it to print out using"The answer is: "+myAnswer. When compiling it has to print out "The answer is: Childs Ticket" but I dont know how to set the value of myAnswer to three different statments (senior ticket, adult ticket, and childs ticket.)
------------------
import java.util.Scanner; //class scanner
public class BusTicket{
public static void main(String args[]){
int myAnswer;
Scanner input = new Scanner(System.in);
System.out.print("Enter age: "); //promt
int userAge = input.nextInt(); //read input from user
if (userAge >=65){
System.out.printf("Senior Ticket");
}
else if (userAge >=18){
System.out.printf("Adult Ticket");
}
else if (userAge 18){
System.out.printf("Childs's Ticket");
}
}//end of main method
}//end Comment Header
Bellow is what I've written so far... I ' m

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!