Question:
Write a program that will calculate the cost of a ticket order and display the receipt for the customer on the screen. There are 2 ticket prices: adult, and senior citizen. Adult seats are $4.50 and senior citizen seats are $3.50. If more than 5 senior citizen tickets are purchased, the customer gets an extra 20% off the of the ticket order. If more than 10 regular seats are purchased, the customer gets an additional 10% off the cost of the order. A customer can only place an order for one type of ticket. Output the type of ticket purchased, the number of tickets purchased, the gross cost, the amount of the discount, and the final cost of the order.
I am having errors with incaompatible varriables comparing float with doubles. Can someone please help me solve this program running.
Thanks a lot
public class lab3 { static Library myLib; public static void main (String [] args) { Library myLib = new Library(); //Instance the Library class int ticketNum; //Number of Tickets char adult; //Ticket Type char senior; char ticketType; final double ADULT_SEAT = 4.50; final double SENIOR_SEAT = 3.50; final double ADULT_DISCOUNT = 0.10; final double SENIOR_DISCOUNT = 0.20; int age; float totalCost; //total cost of the tickets float grossCost; //gross cost without discount float discount; //amount of discount int discountRate; discountRate = 0; //Initializing discount rate to 0 /******************** Start main method *****************/ //Prompt for Ticket Type adult = 0; senior = 0; System.out.println("\n\n"); System.out.print("Ticket Types, adult or senior : "); ticketType = Keyboard.readChar(); if (ticketType == adult || ticketType == senior) { System.out.println("Number of Tickets : "); ticketNum = Keyboard.readInt(); } else{ System.out.println("You have entered invalid ticket type. Please try again"); //clear the screen myLib.clrscr(); } System.out.println("\n\n"); //Calc if(ticketType == adult && ticketNum >=10) { totalCost = grossCost - discount; grossCost = ADULT_SEAT * ticketNum; discount = grossCost * ADULT_DISCOUNT; } else totalCost = ADULT_SEAT * ticketNum; if (ticketType == senior && ticketNum >=5) { totalCost = grossCost - discount; grossCost = SENIOR_SEAT * ticketNum; discount = grossCost * SENIOR_DISCOUNT; } } }//end