Consider a class ConcertPromoter that records the tickets sold for a performance
ID: 3763545 • Letter: C
Question
Consider a class ConcertPromoter that records the tickets sold for a performance. Before the day of the concert, tickets are sold only over the phone. venue. The class has the following attributes:
The name of the band
The capacity of the venue
The Number of tickets sold
The Number of tickets sold by phone
The Number of tickets sold at the venue
The total sales amount It has methods to:
Record the Sales of one or more tickets
Change from phone sales to sales at the concert venue
Return the number of tickets sold
Return the number of tickets remaing
Return the total amount of sales from the concert
a. Write A heading for each method
b. Write Preconditions and post conditions for each method
c . Write Some java statments that test the class
d. Implement the class.
e. List any additional methods and attributes needed in the implementation that were not listed in the original design.List any other changes made to the original design.
f. Write a program using the class you wrote for Part d that will be used to record sales for a concert. Your program should record phone sales, then sales at the venue. As tickets are sold, the number of seats remaining should be displayed. At the end of the program, display the number of tickets sold and the total sales amount for the concert.
Explanation / Answer
Program code:
import java.util.Scanner;
public class concert
{
String bandName;
int capacityOfVenue;
//int noOfTicketsSold;
int noOfTicketsSoldbyPhone;
int noOfTicketsSoldatVenue;
int totalSalesAmount;
int costofTicketAtVenue=50;
int costofTicketbyPhone=70;
public String RecordSales()
{
int totsales=changePhoneSalestoVenueSales(noOfTicketsSoldbyPhone);
int tot=noOfTicketsSoldatVenue+noOfTicketsSoldbyPhone;
int rtickets=remainingTickets(tot);
return totsales+" "+rtickets;
}
int remainingTickets(int tot) {
return capacityOfVenue-tot;
// TODO Auto-generated method stub
}
int changePhoneSalestoVenueSales(int noOfTicketsSoldbyPhone2) {
// TODO Auto-generated method stub
return noOfTicketsSoldatVenue*costofTicketAtVenue+noOfTicketsSoldbyPhone2*costofTicketbyPhone;//=+noOfTicketsSoldbyPhone2;
// return noOfTicketsSoldatVenue;
}
public static void main(String args[])
{
concert c=new concert();
Scanner sc=new Scanner(System.in);
System.out.println("Enter the capacity of the venue");
c.capacityOfVenue=sc.nextInt();
System.out.println("Enter the tickets sold at the venue");
c.noOfTicketsSoldatVenue=sc.nextInt();
System.out.println("Enter the tickets sold by phone");
c.noOfTicketsSoldbyPhone=sc.nextInt();
System.out.println("totalsales remaining tickets:");
System.out.println(c.RecordSales());
//c.noOfTicketsSoldatVenue=sc.nextInt();
}
}
Sample output:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.