Hi there,

I am currently studying Java just over six weeks and am a novice. I have been give a question to do, the question is...

Theatre Ticketing System
Write a program that reads ticket details from the user and outputs those details in the
form of a Theatre ticket which displays the following information:
(i) Surname of Patron :
(ii) Name of Show.
(iii) Number of people in that Party (Validated, see below)
(iv) Cost of the Ticket
The program must read in the Surname, Name of the Show and the number of people in
the Party (Maximum 10 people in any one party )
The price of Ticket may be calculated based on a cost of €35.00 per patron.
So for example if there are 5 people in any one party the cost of that ticket
would be €35.00 * 5
If there are more than 6 people in any party a reduction of 10 % is given on the total
ticket cost.

Hmmm... it's a loaded question I know, but can anyone please help me out with this problem. All help is very much appreciated.

King Regards,
John B.

Please be aware of the following forum rule:
Do provide evidence of having done some work yourself if posting questions from school or work assignments

Post your code and specific questions about what is troubling you and what you have tried.

Hi there,

Sorry for the very late reply I have done alot of the work myself but am having trouble with the very last bit which is the Y/N do while at the very end. The Yes part works but when I choose No it does not break out of the program...

Here my code anyway :)

// Programmer: <removed>
// Student Id: xxxxxxxx
// Date Written: 17th November 2011
// Function: Write a program that reads ticket details from the user and outputs those details in the form of a Theatre ticket which displays the following information.
// Note: Uses Easyin Class

class test1
{
    public static void main(String[] args)
    {
    boolean choice = false; // While loop to take the users input
    while(!choice)
    {
        String name_patron; 	// Defines the Strings
        String name_show;
        double total_ticket=0;	// Defines the Double Integers
        double discount_num;
        char  decision; 		// Defines the Character
        int people_num = 0;		// Defines the Integers

		System.out.println("Theatre Ticket Booking System");
        System.out.println("Surname of Patron: "); 			// Takes the users Surname name from the keyboard
        name_patron = EasyIn.getString();
        System.out.println("Name of the Show: "); 			// Takes the name of the show from the Keyboard
        name_show = EasyIn.getString();

    boolean val_amount = false; // While loop to valadate the number of people greater or less then 10
    while (!val_amount)
    {
        System.out.println("Enter Number of People: "); 	// Takes the number of people from the Keyboard
        people_num = EasyIn.getInt();

    if(people_num < 11) // Verifies that there can be no greater then 10 to a party
    {
	    val_amount = true;}

    else
    {
		System.out.println("");
        System.out.println("ERROR MESSAGE... TOO MANY PATRONS!"); // Error massage appears if there is to many in the party
    }
    }
        total_ticket = people_num * 35; 			// Calcuates the total number of people

    if(people_num > 6) // Valadates if the number of people is greater then 6
    {
        discount_num = ((total_ticket / 100) * 10); // Calcuates the the 10% Discount
        total_ticket = total_ticket - discount_num;
    }
        System.out.println("******************************");
        System.out.println("    Show        : " + name_show); 		// Prints the name of the Show to the screen
        System.out.println("    Surname     : "+ name_patron);		// Prints the Surname to the screen
        System.out.println("    No in Party : " + people_num);		// Prints the number in the party to the screen
        System.out.println("    Cost        : " + total_ticket);	// PrintS the Cost to the screen
        System.out.println("******************************");
    do
	{
	    System.out.println("");
	    System.out.println("Do you want to Process Another Ticket (Y/N)?");
	    System.out.println("       You must type a 'Y' or an 'N'");
	    decision = EasyIn.getChar();
	}
	while((decision !='Y')&&(decision !='N')&&(decision !='y')&&(decision !='n'));
	}
    }
}

Please be aware of the following forum rule:
Do provide evidence of having done some work yourself if posting questions from school or work assignments

Post your code and specific questions about what is troubling you and what you have tried.

I assume that your instructor provided you with the "EasyIn" class. I don't know exactly what it does, but a common problem is that such methods might get the new line ('\r' and '\n') characters that occur at the end of each line.

If you still have problems, consider using 'EasyIn.getString()' instead of ' EasyIn.getChar()'. Then either do string comparisons, or get the first character of the string and use that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.