1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Dafna11 [192]
3 years ago
7

Each ticket has a unique number and a price. There are three types of tickets: walk-up tickets, advance tickets, and student adv

ance tickets. Walk-up tickets are purchased the day of the event and cost $50. Advance tickets purchased 10 or more days before the event cost $30, and advance tickets purchased fewer than 10 days before the event cost $40. Student advance tickets are sold at half the price of normal advance tickets: When they are purchased 10 or more days early they cost $15, and when they are purchased fewer than 10 days early they cost $20. Implement a class called Ticket that will serve as the superclass for all three types of tickets. Define all common operations in this class, and specify all differing operations in such a way that every subclass must implement them. No actual objects of type Ticket will be created: Each actual ticket will be an object of a subclass type. Define the following operations: The ability to construct a ticket by number. The ability to ask for a ticket's price. The ability to println a ticket object as a String. An example String would be "Number: 17, Price: 50.0".
a. Implement a class called WalkupTicket to represent a walk-up event ticket. Walk-up tickets are also constructed by number, and they have a price of $50.
b. Implement a class called AdvanceTicket to represent tickets purchased in advance. An advance ticket is constructed with a ticket number and with the number of days in advance that the ticket was purchased. Advance tickets purchased 10 or more days before the event cost $30, and advance tickets purchased fewer than 10 days before the event cost $40.
c. Implement a class called StudentAdvanceTicket to represent tickets purchased in advance by students. A student advance ticket is constructed with a ticket number and with the number of days in advance that the ticket was purchased. Student advance tickets purchased 10 or more days before the event cost $15, and student.
Computers and Technology
1 answer:
liberstina [14]3 years ago
7 0

Answer:

import java.util.Scanner;

public abstract class Ticket   //abstract base class

   private int number;

   public Ticket(int number)

   

       this.number = number;

   

   public int getNumber()

   

       return number;

   

   public abstract double getPrice();

   public abstract String toString();

public class WalkupTicket extends Ticket

   public WalkupTicket(int number)

   

       super(number);

   

   public double getPrice()

   

       return 50;

   

   public String toString()

   

       return Number : +getNumber() +, Price : +getPrice();

   

public class AdvanceTicket extends Ticket

   private int days;

   public AdvanceTicket(int number)

   

       super(number);

   

   public AdvanceTicket(int number,int days)

   

       super(number);

       this.days = days;

   

   public double getPrice()

   

       if(days>=10)

       return 30;

       else

       return 40;

   

   public String toString()

   

       return Number : +getNumber() +, Price : +getPrice();

   

public class StudentAdvanceTicket extends AdvanceTicket

   private int days;

   public StudentAdvanceTicket(int number,int days)

   

       super(number);

       this.days = days;

   

   public double getPrice()

 

Explanation:

import java.util.Scanner;

public abstract class Ticket   //abstract base class

   private int number;

   public Ticket(int number)

   

       this.number = number;

   

   public int getNumber()

   

       return number;

   

   public abstract double getPrice();

   public abstract String toString();

public class WalkupTicket extends Ticket

   public WalkupTicket(int number)

   

       super(number);

   

   public double getPrice()

   

       return 50;

   

   public String toString()

   

       return Number : +getNumber() +, Price : +getPrice();

   

public class AdvanceTicket extends Ticket

   private int days;

   public AdvanceTicket(int number)

   

       super(number);

   

   public AdvanceTicket(int number,int days)

   

       super(number);

       this.days = days;

   

   public double getPrice()

   

       if(days>=10)

       return 30;

       else

       return 40;

   

   public String toString()

   

       return Number : +getNumber() +, Price : +getPrice();

   

public class StudentAdvanceTicket extends AdvanceTicket

   private int days;

   public StudentAdvanceTicket(int number,int days)

   

       super(number);

       this.days = days;

   

   public double getPrice()

 

You might be interested in
write a program to update the rate by increasing 20% from sequential data file "items.dat" that store item name.rate and quantit
sveticcg [70]

Answer:

your answer is in the pic

(◔‿◔)

。◕‿◕。

6 0
3 years ago
Which sequence represents the hierarchy of terms, from smallest to greatest?
Anni [7]

Answer:

b

Explanation:

7 0
3 years ago
Input 3 positive integers from the terminal, determine if tlrey are valid sides of a triangle. If the sides do form a valid tria
butalik [34]

Answer:

In Python:

side1 = float(input("Side 1: "))

side2 = float(input("Side 2: "))

side3 = float(input("Side 3: "))

if side1>0 and side2>0 and side3>0:

   if side1+side2>=side3 and side2+side3>=side1 and side3+side1>=side2:

       if side1 == side2 == side3:

           print("Equilateral Triangle")

       elif side1 == side2 or side1 == side3 or side2 == side3:

           print("Isosceles Triangle")

       else:

           print("Scalene Triangle")

   else:

       print("Invalid Triangle")

else:

   print("Invalid Triangle")

Explanation:

The next three lines get the input of the sides of the triangle

<em>side1 = float(input("Side 1: ")) </em>

<em>side2 = float(input("Side 2: ")) </em>

<em>side3 = float(input("Side 3: ")) </em>

If all sides are positive

if side1>0 and side2>0 and side3>0:

Check if the sides are valid using the following condition

   if side1+side2>=side3 and side2+side3>=side1 and side3+side1>=side2:

Check if the triangle is equilateral

<em>        if side1 == side2 == side3: </em>

<em>            print("Equilateral Triangle") </em>

Check if the triangle is isosceles

<em>        elif side1 == side2 or side1 == side3 or side2 == side3: </em>

<em>            print("Isosceles Triangle") </em>

Otherwise, it is scalene

<em>        else: </em>

<em>            print("Scalene Triangle") </em>

Print invalid, if the sides do not make a valid triangle

<em>    else: </em>

<em>        print("Invalid Triangle") </em>

Print invalid, if the any of the sides are negative

<em>else: </em>

<em>    print("Invalid Triangle")</em>

4 0
3 years ago
Consider the following code: public static void mystery(int a) { System.out.println("A"); } public static void mystery(double a)
Feliz [49]

Answer:

The output is "A"

Explanation:

public class Solution {

   public static void main(String args[]) {

     mystery(7);

   }    

   public static void mystery(int a) { System.out.println("A"); }    

   public static void mystery(double a) { System.out.println("B"); }    

   public static void mystery(int a, double b) { System.out.println("C"); }    

   public static void mystery(double a, int b) { System.out.println("D"); }

}

In the code above; mystery is defined in four different ways called method overloading. Method overloading is when same method is defined with different parameters.

In the first case; mystery will be called if the argument is int.

In the second case; mystery will be called if the argument is double.

In the third case; mystery will be called if the arguments are int and double.

In the fourth case; mystery will be called if the arguments are double and int.

When mystery(7) is called; the mystery method requiring only int will be called and the output is "A".

3 0
4 years ago
Which type of mountain is formed due to the collision of two different kinds of plates?
Lyrx [107]
D) Andean mountains are formed due to the collision of two different kinds of plates.
6 0
3 years ago
Read 2 more answers
Other questions:
  • What type of interview would be most likely for the following scenario?
    11·2 answers
  • In which part of a browser will you type the url of a website
    11·1 answer
  • Mary from sales is asking about the plan to implement Salesforce.com's application. You explain to her that you are in the proce
    9·1 answer
  • Question 2 (5 points)
    12·1 answer
  • What type of culture is computer hardware?
    6·2 answers
  • Yall like portal 1 or 2
    8·1 answer
  • Declare an ArrayList of Strings. Add eight names to the collection. Output the Strings onto the console using the enhanced for l
    9·1 answer
  • Help plz!! I will mark brainliest
    15·2 answers
  • What refers to a set of instructions executed in order?
    6·1 answer
  • The ____ file is typically saved with a prefix of inc_.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!