Suppose the Great Frederick Fair wants to update its ticketing software. They need you to write a program to handle the price calculations, using the rules*: The basic price of a ticket is $40. Senior citizens (age >= 65) get a 50% discount. Children under 6 are free (100% discount). For residents of Frederick County, the basic price is $35; the same discounts still apply. So the individual ticket prices range from $0 to $40. ● ● ● ● Your program should request age and county name from the user. The age will be entered as an integer and the county name as a string. Before calculating the price, confirm that the user's age is valid - not negative and not more than 110. If it is not, give a message and do not do the price calculation. Also, the county name should not be case sensitive - for example, Frederick, frederick, and FREDERICK should all be acceptable. Your program should then calculate and print out the ticket price, using the appropriate discounts. Test your program with a variety of ages and counties to be sure you have considered all the conditions. Here are some samples. Test run # 1 2 3 4 5 6789 County Frederick Frederick Carroll Howard Washington Frederick Montgomery Carroll Frederick Age 12 72 2 65 0 5 6 35 15
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
Step by step
Solved in 4 steps with 2 images