EVENT.JAVA:
public abstract class Event {
//Fill your code here
protected String name;
protected String detail;
protected String ownerName;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDetail() {
return detail;
}
public void setDetail(String detail) {
this.detail = detail;
}
public String getOwnerName() {
return ownerName;
}
public void setOwnerName(String ownerName) {
this.ownerName = ownerName;
}
public Event(String name, String detail, String ownerName) {
this.name = name;
this.detail = detail;
this.ownerName = ownerName;
}
public abstract Double projectedRevenue();
}
public abstract class Event { //Fill your code here protected String name; protected String detail; protected String ownerName; public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDetail() { return detail; } public void setDetail(String detail) { this.detail = detail; } public String getOwnerName() { return ownerName; } public void setOwnerName(String ownerName) { this.ownerName = ownerName; } public Event(String name, String detail, String ownerName) { this.name = name; this.detail = detail; this.ownerName = ownerName; } public abstract Double projectedRevenue(); }
EXHINITION.JAVA:
public class Exhibition extends Event {
private int noOfStalls;
public Exhibition(String name, String detail, String ownerName, int noOfStalls) {
super(name, detail, ownerName);
this.noOfStalls = noOfStalls;
}
public Double projectedRevenue(){
return 10000.0*noOfStalls;
}
public int getNoOfStalls() {
return noOfStalls;
}
public void setNoOfStalls(int noOfStalls) {
this.noOfStalls = noOfStalls;
}
}
public class Exhibition extends Event { private int noOfStalls; public Exhibition(String name, String detail, String ownerName, int noOfStalls) { super(name, detail, ownerName); this.noOfStalls = noOfStalls; } public Double projectedRevenue(){ return 10000.0*noOfStalls; } public int getNoOfStalls() { return noOfStalls; } public void setNoOfStalls(int noOfStalls) { this.noOfStalls = noOfStalls; } }
STAGEVENT.JAVA:
public class StageEvent extends Event{
private int noOfShows;
private int noOfSeatsPerShow;
public StageEvent(String name, String detail, String ownerName, int noOfShows, int noOfSeatsPerShow) {
super(name, detail, ownerName);
this.noOfShows = noOfShows;
this.noOfSeatsPerShow = noOfSeatsPerShow;
}
@Override
public java.lang.Double projectedRevenue() {
return (double) noOfShows*noOfSeatsPerShow*50;
}
}
public class StageEvent extends Event{ private int noOfShows; private int noOfSeatsPerShow; public StageEvent(String name, String detail, String ownerName, int noOfShows, int noOfSeatsPerShow) { super(name, detail, ownerName); this.noOfShows = noOfShows; this.noOfSeatsPerShow = noOfSeatsPerShow; } @Override public java.lang.Double projectedRevenue() { return (double) noOfShows*noOfSeatsPerShow*50; } }
MAIN.JAVA:import java.io.IOException;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the name of the event:");
String name=sc.nextLine();
System.out.println("Enter the detail of the event:");
String detail=sc.nextLine();
System.out.println("Enter the owner name of the event:");
String owner=sc.nextLine();
System.out.println("Enter the type of the event:\n1.Exhibition\n2.StageEvent");
int n=sc.nextInt();
switch (n)
{
case 1:
System.out.println("Enter the number of stalls:");
int stall=sc.nextInt();
Event e=new Exhibition(name,detail,owner,stall);
System.out.println("The projected revenue of the event is "+e.projectedRevenue());
break;
case 2:
System.out.println("Enter the number of shows:");
int show=sc.nextInt();
System.out.println("Enter the number of seats per show:");
int seat=sc.nextInt();
Event s=new StageEvent(name,detail,owner,show,seat);
System.out.println("The projected revenue of the event is "+s.projectedRevenue());
break;
}
}
}
import java.io.IOException; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); System.out.println("Enter the name of the event:"); String name=sc.nextLine(); System.out.println("Enter the detail of the event:"); String detail=sc.nextLine(); System.out.println("Enter the owner name of the event:"); String owner=sc.nextLine(); System.out.println("Enter the type of the event:\n1.Exhibition\n2.StageEvent"); int n=sc.nextInt(); switch (n) { case 1: System.out.println("Enter the number of stalls:"); int stall=sc.nextInt(); Event e=new Exhibition(name,detail,owner,stall); System.out.println("The projected revenue of the event is "+e.projectedRevenue()); break; case 2: System.out.println("Enter the number of shows:"); int show=sc.nextInt(); System.out.println("Enter the number of seats per show:"); int seat=sc.nextInt(); Event s=new StageEvent(name,detail,owner,show,seat); System.out.println("The projected revenue of the event is "+s.projectedRevenue()); break; } } }