A baseball team plays in a stadium that holds 100000 spectators. When the ticket price is 7 dollars the average attendance is 45000. When the price is dropped to 5 dollars then the average attendance rises to 50000. Find the demand function and how should the ticket price be set to maximize revenue?