I'm having some trouble with my code. I want to calculate the final balances of some movie tickets based on their day or night showing (and depending on if they are children or adults). So at the end of the code, I've been trying to get the solution to a variable that I had in the second while loop. It seems like I have to have the variables !time.equalsIgnoreCase("D") and !time.equalsIgnoreCase("E") in the second while loop. I've read that a variable terminates after the loop is done. Can someone please help me out?

import java.util.Scanner;															// Needed for the Scanner class
import java.text.NumberFormat;														// Needed for number format class

public class movie 
	
{
	// Create a Scanner object to read input.
	static Scanner keyboard = new Scanner (System.in);
	
	public static void main(String[ ] args)
	
	{
		boolean cinema = true;														// Needed to apply master loop.
		boolean validInput;															// Needed to apply initial loop.
		boolean fullday;															// Needed to apply initial loop.
		boolean list = true;														// Needed to apply secondary loop.
		boolean decision=true;														// Needed to apply secondyloop.
		boolean yesno = true;														// Needed to apply secondary loop.
		
		NumberFormat nf = NumberFormat.getNumberInstance( );						// Defines the number format.
		double adult = 8.25;														// Stores the adult ticket price.
		double day;																	// Stores the day time ticket price.
		double children1;															// Stores the children ticket prices.
		double children2;															// Stores the children ticket prices.
		double total1;																// Stores the total cost.
		double total2;																// Stores the total cost.
		double total;																// Stores the overall total cost.
		int atickets;																// Stores the number of adult tickets.
		int ctickets;																// Stores the number of child tickets.
		int enter;																	// To hold the movie choice.
		int capacity;																// The total theater capacity.
		String answer;																// To hold an answer to the first Yes or No question.
		String answer2;																// To hold an answer to the Day or Evening question.
		String time;																// To hold an answer to the Day or Evening question.
		String sol;																	// To hold an answer to the second Yes or No question.
		
		nf.setMinimumFractionDigits(2);												// Sets the minimum decimal places.
		nf.setMaximumFractionDigits(2);												// Sets the maximum decimal places.
	
		System.out.println("\nWelcome to the Movie Theater");
		
					
					// Calculate the price of a day ticket.
					day = adult * 0.80;
		
					// Calculate the price of a child's ticket based on the evening price.
					children1 = adult * 0.70;
		
					// Calculate the price of a child's ticket based on the day price.
					children2 = day * 0.70;
		
		while(cinema)
		{
			while(list)
			{
					System.out.println("\nHere are the movies showing presently: ");
		
					System.out.println(" ");
		
					System.out.println("           Title" + "					   Daytime Price" + "	Child Daytime Price"+ "		Evening Price" + "		Child Evening Price");
					System.out.println("-----------------------------------------------------------------------------------------------------------------------------------------------------------");
					System.out.println("1. Burn After Reading						" + nf.format(day) + "		       " + nf.format(children2) + "			     " + nf.format(adult) + "			" + nf.format(children1));
					System.out.println("2. Journey to the Center of the Earth 3D			" + nf.format(day) + "		       " + nf.format(children2) + "			     " + nf.format(adult) + "			" + nf.format(children1));
					System.out.println("3. Tropic Thunder						" + nf.format(day) + "		       " + nf.format(children2) + "			     " + nf.format(adult) + "			" + nf.format(children1));
					System.out.println("4. Lakeview Terrace						" + nf.format(day) + "		       " + nf.format(children2) + "			     " + nf.format(adult) + "			" + nf.format(children1));
		
					System.out.println(" ");
			
			System.out.print("\nPlease choose a movie number: ");
			
			do
			{	
					
						enter = keyboard.nextInt( );																// Stores the chosen movie.
						validInput = true;
						if ( (enter < 1) || (enter > 4))															// Defines the invalid boundaries (but true by definition).
						{
							System.out.print ("\n(You must pick a movie 1 through 4): ");
							validInput = false;										 
						}
				
			}
			
			while(!validInput);
			
			
			
		
			System.out.print("\nYou chose movie number " + enter + ". Is this correct? (Y or N)?: ");
			
			do
			{
						
						answer = keyboard.next ();	
						yesno = true;
						if (!answer.equalsIgnoreCase("Y") && !answer.equalsIgnoreCase("N"))							// Defines the invalid boundaries (but true by definition).
						{
							System.out.print ("\n(You must pick Y or N): ");
							yesno = false;
							
						}
			}
				
			while (!yesno);
			
			do
			{
				if (answer.equalsIgnoreCase("N"));																// Ignores case sensitivity.
				else if (answer.equalsIgnoreCase("Y"))															// Ignores case sensitivity.
					list = false;																				// If Yes is recorded, then we may proceed. If no is recorded, then we begin the loop over again.
				else
					yesno = false;
				
			}
			
				while (!yesno);
			
			}
			
			while(decision)
			{
			System.out.print("\nIs this a day or an evening show?: (Please answer with D for day or E for evening): ");
			
			do																									// Makes sure the movie choice is valid.
			{
				
				time = keyboard.next( );																		// Stores the chosen movie.
				fullday = true;
				if  (!time.equalsIgnoreCase("D") && !time.equalsIgnoreCase("E"))								// Defines the invalid boundaries (but true by definition).
				{
					System.out.print ("\n(You must type in D or E): ");
					fullday = false;										 
				}
			}
			
			while (!fullday);
			
			System.out.print("\nYou chose " + time + ". Is this correct? (Y or N)?: ");
			
			
			do																									// Asks the user if he/she is sure of the choice. If yes, then the program continues on. If not, the program loops back to the beginning menu.
			{
				
				answer2 = keyboard.next ();																		// Stores the answer to the question above.
				fullday = true;																					// If Yes is recorded, then we may proceed. If no is recorded, then we begin the loop over again.
				if (!answer2.equalsIgnoreCase("Y") && !answer2.equalsIgnoreCase("N"))	
				{
					System.out.print ("\n(You must pick Y or N): ");
					fullday = false;
					
				}
			}
				
				while (!fullday);
				
			do
			{
				
				if (answer2.equalsIgnoreCase("N"));																// Ignores case sensitivity.
				else if (answer2.equalsIgnoreCase("Y"))															// Ignores case sensitivity.
					decision = false;																	// If Yes is recorded, then we may proceed. If no is recorded, then we begin the loop over again.
				else
					fullday = false;
			}
			
			
				while(!fullday);	
			}
			
			
			
			// Calculate the adult tickets.
			System.out.print("\nHow many adult tickets would you like to purchase?: ");
			atickets = keyboard.nextInt( );
			
			// Calculate the children's tickets.
			System.out.print("\nHow many children's tickets would you like to purchase?: ");
			ctickets = keyboard.nextInt( );
			
			// Calculate the final balance based on the day or evening pick.
			if (time.equalsIgnoreCase("D"))
				total1 = atickets * day + ctickets * children2;
			else if (time.equalsIgnoreCase("E"))
				total2 = atickets * adult + ctickets + children1;
			
			// Calculate the final balance.
			total = total1 + total 2;
			System.out.println("Your total is $" + nf.format(total) + ".");
								
								 
								 
			
			break;
			
			
			
						
		}	
			
			
						
			
			
			
			
	
		
	}	
	
}

Recommended Answers

All 7 Replies

I just made some small changes to your code:

  • initialized variables
  • moved calculation block out of while loop
import java.util.Scanner;			// Needed for the Scanner class
import java.text.NumberFormat;		// Needed for number format class

public class Movie 
	
{
	// Create a Scanner object to read input.
	static Scanner keyboard = new Scanner (System.in);
	
	public static void main(String[ ] args)
	
	{
		boolean cinema = true;			// Needed to apply master loop.
		boolean validInput;				// Needed to apply initial loop.
		boolean fullday;				// Needed to apply initial loop.
		boolean list = true;			// Needed to apply secondary loop.
		boolean decision=true;			// Needed to apply secondyloop.
		boolean yesno = true;			// Needed to apply secondary loop.
		
		NumberFormat nf = NumberFormat.getNumberInstance( );	// Defines the number format.
		double adult = 8.25;			// Stores the adult ticket price.
		double day = 0.0;				// Stores the day time ticket price.
		double children1 = 0.0;			// Stores the children ticket prices.
		double children2 = 0.0;			// Stores the children ticket prices.
		double total1 = 0.0;			// Stores the total cost.
		double total2 = 0.0;			// Stores the total cost.
		double total = 0.0;				// Stores the overall total cost.
		int atickets = 0;				// Stores the number of adult tickets.
		int ctickets = 0;				// Stores the number of child tickets.
		int enter = 0;					// To hold the movie choice.
		int capacity = 0;				// The total theater capacity.
		String answer = null;			// To hold an answer to the first Yes or No question.
		String answer2 = null;			// To hold an answer to the Day or Evening question.
		String time = null;				// To hold an answer to the Day or Evening question.
		String sol = null;				// To hold an answer to the second Yes or No question.
		
		nf.setMinimumFractionDigits(2);		// Sets the minimum decimal places.
		nf.setMaximumFractionDigits(2);		// Sets the maximum decimal places.
	
		System.out.println("\nWelcome to the Movie Theater");
		
					
					// Calculate the price of a day ticket.
					day = adult * 0.80;
		
					// Calculate the price of a child's ticket based on the evening price.
					children1 = adult * 0.70;
		
					// Calculate the price of a child's ticket based on the day price.
					children2 = day * 0.70;
		
		while(cinema)
		{
			while(list)
			{
				System.out.println("\nHere are the movies showing presently: ");
		
				System.out.println(" ");
		
				System.out.println("           Title" + "					   Daytime Price" + "	Child Daytime Price"+ "		Evening Price" + "		Child Evening Price");
				System.out.println("-----------------------------------------------------------------------------------------------------------------------------------------------------------");
				System.out.println("1. Burn After Reading						" + nf.format(day) + "		       " + nf.format(children2) + "			     " + nf.format(adult) + "			" + nf.format(children1));
				System.out.println("2. Journey to the Center of the Earth 3D			" + nf.format(day) + "		       " + nf.format(children2) + "			     " + nf.format(adult) + "			" + nf.format(children1));
				System.out.println("3. Tropic Thunder						" + nf.format(day) + "		       " + nf.format(children2) + "			     " + nf.format(adult) + "			" + nf.format(children1));
				System.out.println("4. Lakeview Terrace						" + nf.format(day) + "		       " + nf.format(children2) + "			     " + nf.format(adult) + "			" + nf.format(children1));
		
				System.out.println(" ");
			
				System.out.print("\nPlease choose a movie number: ");
				
				do
				{
					enter = keyboard.nextInt( );			// Stores the chosen movie.
					validInput = true;
					if ( (enter < 1) || (enter > 4))		// Defines the invalid boundaries (but true by definition).
					{
						System.out.print ("\n(You must pick a movie 1 through 4): ");
						validInput = false;										 
					}				
				}while(!validInput);			
				
			
				System.out.print("\nYou chose movie number " + enter + ". Is this correct? (Y or N)?: ");
				
				do
				{
					answer = keyboard.next ();
					yesno = true;
					if (!answer.equalsIgnoreCase("Y") && !answer.equalsIgnoreCase("N"))	// Defines the invalid boundaries (but true by definition).
					{
						System.out.print ("\n(You must pick Y or N): ");
						yesno = false;
					}
				}while (!yesno);
				
				do
				{
					if (answer.equalsIgnoreCase("N"));			// Ignores case sensitivity.
					else if (answer.equalsIgnoreCase("Y"))		// Ignores case sensitivity.
						list = false;							// If Yes is recorded, then we may proceed. If no is recorded, then we begin the loop over again.
					else
						yesno = false;
					
				}while (!yesno);
			
			}
			
			while(decision)
			{
				System.out.print("\nIs this a day or an evening show?: (Please answer with D for day or E for evening): ");
				
				do												// Makes sure the movie choice is valid.
				{
					
					time = keyboard.next( );					// Stores the chosen movie.
					fullday = true;
					if  (!time.equalsIgnoreCase("D") && !time.equalsIgnoreCase("E"))	// Defines the invalid boundaries (but true by definition).
					{
						System.out.print ("\n(You must type in D or E): ");
						fullday = false;										 
					}
				}while (!fullday);
				
				System.out.print("\nYou chose " + time + ". Is this correct? (Y or N)?: ");
				
				
				do												// Asks the user if he/she is sure of the choice. If yes, then the program continues on. If not, the program loops back to the beginning menu.
				{
					
					answer2 = keyboard.next ();					// Stores the answer to the question above.
					fullday = true;								// If Yes is recorded, then we may proceed. If no is recorded, then we begin the loop over again.
					if (!answer2.equalsIgnoreCase("Y") && !answer2.equalsIgnoreCase("N"))	
					{
						System.out.print ("\n(You must pick Y or N): ");
						fullday = false;
						
					}
				}while (!fullday);
					
				do
				{
					
					if (answer2.equalsIgnoreCase("N"));			// Ignores case sensitivity.
					else if (answer2.equalsIgnoreCase("Y"))		// Ignores case sensitivity.
						decision = false;						// If Yes is recorded, then we may proceed. If no is recorded, then we begin the loop over again.
					else
						fullday = false;
				}while(!fullday);	
			}			
			
			// Calculate the adult tickets.
			System.out.print("\nHow many adult tickets would you like to purchase?: ");
			atickets = keyboard.nextInt( );
			
			// Calculate the children's tickets.
			System.out.print("\nHow many children's tickets would you like to purchase?: ");
			ctickets = keyboard.nextInt( );
			break;			
		}
		// Calculate the final balance based on the day or evening pick.
		if (time.equalsIgnoreCase("D"))
			total1 = atickets * day + ctickets * children2;
		else if (time.equalsIgnoreCase("E"))
			total2 = atickets * adult + ctickets + children1;
		
		// Calculate the final balance.
		total = total1 + total2;
		System.out.println("Your total is $" + nf.format(total) + ".");	
	}		
}

Thanks...that helped a lot. I just have one more question...well actually 2. I'm trying to make the number of tickets positive such that negative numbers will spit out an error and the customer will have to re enter a positive number of tickets. When I compile the program...it goes as far as asking for the appropriate number of tickets but then doesn't go any further. Below is my code.

Also the number of tickets needs to be capped off at 100. Can someone suggest how I can accomplish this? Thanks again.

import java.util.Scanner;			// Needed for the Scanner class
import java.text.NumberFormat;		// Needed for number format class

public class Movie 
	
	{
		// Create a Scanner object to read input.
		static Scanner keyboard = new Scanner (System.in);
		
		public static void main(String[ ] args)
		
		{
			boolean cinema = true;			// Needed to apply master loop.
			boolean validInput;				// Needed to apply initial loop.
			boolean fullday;				// Needed to apply initial loop.
			boolean positive;
			boolean list = true;			// Needed to apply secondary loop.
			boolean decision=true;			// Needed to apply secondyloop.
			boolean yesno = true;			// Needed to apply secondary loop.
			
			NumberFormat nf = NumberFormat.getNumberInstance( );	// Defines the number format.
			double adult = 8.25;			// Stores the adult ticket price.
			double day = 0.0;				// Stores the day time ticket price.
			double children1 = 0.0;			// Stores the children ticket prices.
			double children2 = 0.0;			// Stores the children ticket prices.
			double total1 = 0.0;			// Stores the total cost.
			double total2 = 0.0;			// Stores the total cost.
			double total = 0.0;				// Stores the overall total cost.
			int atickets = 0;				// Stores the number of adult tickets.
			int ctickets = 0;				// Stores the number of child tickets.
			int enter = 0;					// To hold the movie choice.
			int capacity = 0;				// The total theater capacity.
			String answer = null;			// To hold an answer to the first Yes or No question.
			String answer2 = null;			// To hold an answer to the Day or Evening question.
			String time = null;				// To hold an answer to the Day or Evening question.
			String sol = null;				// To hold an answer to the second Yes or No question.
			
			nf.setMinimumFractionDigits(2);		// Sets the minimum decimal places.
			nf.setMaximumFractionDigits(2);		// Sets the maximum decimal places.
			
			System.out.println("\nWelcome to the Movie Theater");
			
			
			// Calculate the price of a day ticket.
			day = adult * 0.80;
			
			// Calculate the price of a child's ticket based on the evening price.
			children1 = adult * 0.70;
			
			// Calculate the price of a child's ticket based on the day price.
			children2 = day * 0.70;
			
			while(cinema)
			{
				while(list)
				{
					System.out.println("\nHere are the movies showing presently: ");
					
					System.out.println(" ");
					
					System.out.println("           Title" + "					   Daytime Price" + "	Child Daytime Price"+ "		Evening Price" + "		Child Evening Price");
					System.out.println("-----------------------------------------------------------------------------------------------------------------------------------------------------------");
					System.out.println("1. Burn After Reading						" + nf.format(day) + "		       " + nf.format(children2) + "			     " + nf.format(adult) + "			" + nf.format(children1));
					System.out.println("2. Journey to the Center of the Earth 3D			" + nf.format(day) + "		       " + nf.format(children2) + "			     " + nf.format(adult) + "			" + nf.format(children1));
					System.out.println("3. Tropic Thunder						" + nf.format(day) + "		       " + nf.format(children2) + "			     " + nf.format(adult) + "			" + nf.format(children1));
					System.out.println("4. Lakeview Terrace						" + nf.format(day) + "		       " + nf.format(children2) + "			     " + nf.format(adult) + "			" + nf.format(children1));
					
					System.out.println(" ");
					
					System.out.print("\nPlease choose a movie number: ");
					
					do
					{
						enter = keyboard.nextInt( );			// Stores the chosen movie.
						validInput = true;
						if ( (enter < 1) || (enter > 4))		// Defines the invalid boundaries (but true by definition).
						{
							System.out.print ("\n(You must pick a movie 1 through 4): ");
							validInput = false;										 
						}				
					}while(!validInput);			
					
					
					System.out.print("\nYou chose movie number " + enter + ". Is this correct? (Y or N)?: ");
					
					do
					{
						answer = keyboard.next ();
						yesno = true;
						if (!answer.equalsIgnoreCase("Y") && !answer.equalsIgnoreCase("N"))	// Defines the invalid boundaries (but true by definition).
						{
							System.out.print ("\n(You must pick Y or N): ");
							yesno = false;
						}
					}while (!yesno);
					
					do
					{
						if (answer.equalsIgnoreCase("N"));			// Ignores case sensitivity.
						else if (answer.equalsIgnoreCase("Y"))		// Ignores case sensitivity.
							list = false;							// If Yes is recorded, then we may proceed. If no is recorded, then we begin the loop over again.
						else
							yesno = false;
						
					}while (!yesno);
					
				}
				
				while(decision)
				{
					System.out.print("\nIs this a day or an evening show?: (Please answer with D for day or E for evening): ");
					
					do												// Makes sure the movie choice is valid.
					{
						
						time = keyboard.next( );					// Stores the chosen movie.
						fullday = true;
						if  (!time.equalsIgnoreCase("D") && !time.equalsIgnoreCase("E"))	// Defines the invalid boundaries (but true by definition).
						{
							System.out.print ("\n(You must type in D or E): ");
							fullday = false;										 
						}
					}while (!fullday);
					
					System.out.print("\nYou chose " + time + ". Is this correct? (Y or N)?: ");
					
					
					do												// Asks the user if he/she is sure of the choice. If yes, then the program continues on. If not, the program loops back to the beginning menu.
					{
						
						answer2 = keyboard.next ();					// Stores the answer to the question above.
						fullday = true;								// If Yes is recorded, then we may proceed. If no is recorded, then we begin the loop over again.
						if (!answer2.equalsIgnoreCase("Y") && !answer2.equalsIgnoreCase("N"))	
						{
							System.out.print ("\n(You must pick Y or N): ");
							fullday = false;
							
						}
					}while (!fullday);
					
					do
					{
						
						if (answer2.equalsIgnoreCase("N"));			// Ignores case sensitivity.
						else if (answer2.equalsIgnoreCase("Y"))		// Ignores case sensitivity.
							decision = false;						// If Yes is recorded, then we may proceed. If no is recorded, then we begin the loop over again.
						else
							fullday = false;
					}while(!fullday);	
					
				}			
				
				// Calculate the adult tickets.
				System.out.print("\nHow many adult tickets would you like to purchase?: ");
				atickets = keyboard.nextInt( );
				
				// Calculate the children's tickets.
				System.out.print("\nHow many children's tickets would you like to purchase?: ");
				ctickets = keyboard.nextInt( );
			
				do
				{
					enter = keyboard.nextInt( );			// Stores the chosen number of tickets.
					positive = true;
					if ( (total1 < 0) || (total2 < 0))		// Defines the invalid boundaries (but true by definition).
					{
						System.out.print ("\n(You must pick a positive number): ");
						positive = false;										 
					}				
				}while(!positive);	
				
				break;
			}
			
			
			// Calculate the final balance based on the day or evening pick.
			if (time.equalsIgnoreCase("D"))
				total1 = atickets * day + ctickets * children2;
			else if (time.equalsIgnoreCase("E"))
				total2 = atickets * adult + ctickets + children1;
			
			
			// Calculate the final balance.
			total = total1 + total2;
			System.out.println("\nYour total is $" + nf.format(total) + ".");	
		}		
	}

You can use a do while loop to restrict no. of tickets entered from being negative or greater than 100.

Ex:

do{
System.out.println("How many tickets ?");
atickets = keyboard.nextInt();
// check for input being in the range (not < 0 and not > 100)
// if input is in range set flag to true
}while(flag==false);

I tried the above but I couldn't get it to work. I need the total number of tickets to be 100 or less (atickets + ctickets) but it seems that the compiler is ignoring my loop. Please help.

Actually scratch that last post...I got it to work. Now the final thing I would appreciate help with is how to limit the total number of tickets to 100. Here is my code

import java.util.Scanner;			// Needed for the Scanner class
import java.text.NumberFormat;		// Needed for number format class

public class Movie 
	
	{
		// Create a Scanner object to read input.
		static Scanner keyboard = new Scanner (System.in);
		
		public static void main(String[ ] args)
		
		{
			boolean cinema = true;			// Needed to apply master loop.
			boolean validInput;				// Needed to apply initial loop.
			boolean fullday;				// Needed to apply initial loop.
			boolean positive = true;
			boolean list = true;			// Needed to apply secondary loop.
			boolean decision = true;		// Needed to apply secondyloop.
			boolean yesno = true;			// Needed to apply secondary loop.
			
			NumberFormat nf = NumberFormat.getNumberInstance( );	// Defines the number format.
			double adult = 8.25;			// Stores the adult ticket price.
			double day = 0.0;				// Stores the day time ticket price.
			double children1 = 0.0;			// Stores the children ticket prices.
			double children2 = 0.0;			// Stores the children ticket prices.
			double total1 = 0.0;			// Stores the total cost.
			double total2 = 0.0;			// Stores the total cost.
			double total = 0.0;				// Stores the overall total cost.
			int atickets = 0;				// Stores the number of adult tickets.
			int ctickets = 0;				// Stores the number of child tickets.
			int enter = 0;					// To hold the movie choice.
			int capacity = 0;				// The total theater capacity.
			String answer = null;			// To hold an answer to the first Yes or No question.
			String answer2 = null;			// To hold an answer to the Day or Evening question.
			String time = null;				// To hold an answer to the Day or Evening question.
			String sol = null;				// To hold an answer to the second Yes or No question.
			
			nf.setMinimumFractionDigits(2);		// Sets the minimum decimal places.
			nf.setMaximumFractionDigits(2);		// Sets the maximum decimal places.
			
			System.out.println("\nWelcome to the Movie Theater");
			
			
			// Calculate the price of a day ticket.
			day = adult * 0.80;
			
			// Calculate the price of a child's ticket based on the evening price.
			children1 = adult * 0.70;
			
			// Calculate the price of a child's ticket based on the day price.
			children2 = day * 0.70;
			
			while(cinema)
			{
				while(list)
				{
					System.out.println("\nHere are the movies showing presently: ");
					
					System.out.println(" ");
					
					System.out.println("           Title" + "					   Daytime Price" + "	Child Daytime Price"+ "		Evening Price" + "		Child Evening Price");
					System.out.println("-----------------------------------------------------------------------------------------------------------------------------------------------------------");
					System.out.println("1. Burn After Reading						" + nf.format(day) + "		       " + nf.format(children2) + "			     " + nf.format(adult) + "			" + nf.format(children1));
					System.out.println("2. Journey to the Center of the Earth 3D			" + nf.format(day) + "		       " + nf.format(children2) + "			     " + nf.format(adult) + "			" + nf.format(children1));
					System.out.println("3. Tropic Thunder						" + nf.format(day) + "		       " + nf.format(children2) + "			     " + nf.format(adult) + "			" + nf.format(children1));
					System.out.println("4. Lakeview Terrace						" + nf.format(day) + "		       " + nf.format(children2) + "			     " + nf.format(adult) + "			" + nf.format(children1));
					
					System.out.println(" ");
					
					System.out.print("\nPlease choose a movie number: ");
					
					do
					{
						enter = keyboard.nextInt( );			// Stores the chosen movie.
						validInput = true;
						if ( (enter < 1) || (enter > 4))		// Defines the invalid boundaries (but true by definition).
						{
							System.out.print ("\n(You must pick a movie 1 through 4): ");
							validInput = false;										 
						}				
					}while(!validInput);			
					
					
					System.out.print("\nYou chose movie number " + enter + ". Is this correct? (Y or N)?: ");
					
					do
					{
						answer = keyboard.next ();
						yesno = true;
						if (!answer.equalsIgnoreCase("Y") && !answer.equalsIgnoreCase("N"))	// Defines the invalid boundaries (but true by definition).
						{
							System.out.print ("\n(You must pick Y or N): ");
							yesno = false;
						}
					}while (!yesno);
					
					do
					{
						if (answer.equalsIgnoreCase("N"));			// Ignores case sensitivity.
						else if (answer.equalsIgnoreCase("Y"))		// Ignores case sensitivity.
							list = false;							// If Yes is recorded, then we may proceed. If no is recorded, then we begin the loop over again.
						else
							yesno = false;
						
					}while (!yesno);
					
				}
				
				while(decision)
				{
					System.out.print("\nIs this a day or an evening show?: (Please answer with D for day or E for evening): ");
					
					do												// Makes sure the movie choice is valid.
					{
						
						time = keyboard.next( );					// Stores the chosen movie.
						fullday = true;
						if  (!time.equalsIgnoreCase("D") && !time.equalsIgnoreCase("E"))	// Defines the invalid boundaries (but true by definition).
						{
							System.out.print ("\n(You must type in D or E): ");
							fullday = false;										 
						}
					}while (!fullday);
					
					System.out.print("\nYou chose " + time + ". Is this correct? (Y or N)?: ");
					
					
					do												// Asks the user if he/she is sure of the choice. If yes, then the program continues on. If not, the program loops back to the beginning menu.
					{
						
						answer2 = keyboard.next ();					// Stores the answer to the question above.
						fullday = true;								// If Yes is recorded, then we may proceed. If no is recorded, then we begin the loop over again.
						if (!answer2.equalsIgnoreCase("Y") && !answer2.equalsIgnoreCase("N"))	
						{
							System.out.print ("\n(You must pick Y or N): ");
							fullday = false;
							
						}
					}while (!fullday);
					
					do
					{
						
						if (answer2.equalsIgnoreCase("N"));			// Ignores case sensitivity.
						else if (answer2.equalsIgnoreCase("Y"))		// Ignores case sensitivity.
							decision = false;						// If Yes is recorded, then we may proceed. If no is recorded, then we begin the loop over again.
						else
							fullday = false;
					}while(!fullday);	
					
				}			
				
				
				do
				{
					System.out.print("How many adult tickets? ");
					atickets = keyboard.nextInt( );			// Stores the chosen number of tickets.
					System.out.print("How many children's tickets? ");
					ctickets = keyboard.nextInt( );
					positive = true;
					if ( (atickets < 0) || (ctickets < 0))		// Defines the invalid boundaries (but true by definition).
					{
						System.out.println("\n(You must pick a positive number): ");
						positive = false;										 
					}				
				}while(!positive);
				
				break;
			}
		
				
					
			
			// Calculate the final balance based on the day or evening pick.
			if (time.equalsIgnoreCase("D"))
				total1 = atickets * day + ctickets * children2;
			else if (time.equalsIgnoreCase("E"))
				total2 = atickets * adult + ctickets + children1;
			
			
			// Calculate the final balance.
			total = total1 + total2;
			System.out.println("\nYour total is $" + nf.format(total) + ".");
		}		
	}

You could flash this information at the start that the total number of tickets would be restricted to 100. Now, when suppose, he enters the number of adult tickets to be 70, you again flash him that the total count is capped off at 100 of which 70 he has already booked, so that he can at the most book only 30 child tickets.
The adult ticket number is to be checked to be in between 0 and 100 whereas the child ticket number is to be between 0 and 100 - no. of adult tickets.

Thanks to everyone for your help. The program works the way it should now.

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.