Java Programming Quiz Question?

AkiraY

New member
Joined
Nov 14, 2008
Messages
3
Reaction score
0
Points
1
You purchase tickets for you and your friends to attend a concert. The tickets cost $23.45 (double) each and you need to purchase a total of 7 tickets ( int ). Write a program that will generate the total (double).

The program also tells us how much GST TAX we have to pay on the ticket purchase (total*0.06) and will also tell us the total we have to pay (total*1.06).

output

Subtotal 164.15

Tax GST 9.849

Total 173.99900000000002
 
I haven't included the console writes, as my Java is a bit rusty and I can't remember the method call! I'm sure you can fill those bits in though.

double ticketPrice = 23.45;
int numTickets = 7;
double taxRate = 0.06;
double totalWithoutTax, totalWithTax, tax;

totalWithoutTax = ticketPrice * numTickets;
tax = totalWithoutTax * taxRate;
totalWithTax = totalWithoutTax + tax;

//Output totalWithoutTax here
//Output tax here
//Output totalWithTax here
 
Back
Top