Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a java application called EventTest.java that lets the user create two Eve

ID: 3798714 • Letter: W

Question

Write a java application called EventTest.java that lets the user create two Event objects and then prints the following sample output. Enter title of the first event: New Student Welcome Enter venue of the first event: Student Union Building Enter the date of the first event (MM/dd/yyyy): 07/22/2016 Enter duration for first event: 2.5 Enter title of the second event: Job Fair Enter venue of the second event: University Career Center Enter the date of the second event (MM/dd/yyyy): 07/26/2016 Enter duration for second event: 6 "Student Orientation" event will take place on 07/22/2016 for 2.5 hours in Student Union Building "Job Fair" event will take place on 07/26/2016 for 6 hours in University Career Center. Rewrite your code and create a class date and use it (instead of using a GregorianCalendar), and test it again.

Explanation / Answer

package bbb;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.text.DateFormat;

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Date;

public class EventTest

{

   private String event;

   private String venue;

   private Date date;

   private float duration;

  

   DateFormat format = new SimpleDateFormat("MM/dd/yyyy");

  

  

   public String getEvent()

   {

       return event;

   }

   public void setEvent(String event) {

      

       this.event = event;

   }

   public String getVenue()

   {

       return venue;

   }

   public void setVenue(String venue)

   {

       this.venue = venue;

   }

   public Date getDate()

   {

       return date;

   }

   public void setDate(String date1)

   {

       try

       {

           this.date = format.parse(date1);

       }

       catch (ParseException e)

       {

          

           e.printStackTrace();

       }

   }

   public float getDuration()

   {

       return duration;

   }

   public void setDuration(float duration)

   {

       this.duration = duration;

   }

  

   public static void main(String s[]) throws IOException

   {

       DateFormat format = new SimpleDateFormat("MM/dd/yyyy");

       EventTest obj1=new EventTest();

       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

       System.out.println("Enter Title Of the First Event: ");

       String ss = br.readLine();

       obj1.setEvent(ss);

       System.out.println("Enter venue Of the First Event: ");

       ss=br.readLine();

       obj1.setVenue(ss);

       System.out.println("Enter Date Of the First Event(MM/dd/yyyy):");

       ss=br.readLine();

       obj1.setDate(ss);

       System.out.println("Enter duration Of the First Event: ");

       ss=br.readLine();

       int time=Integer.parseInt(ss);

       obj1.setDuration(time);

      

       EventTest obj2=new EventTest();

      

       System.out.println("Enter Title Of the Second Event: ");

       ss = br.readLine();

       obj2.setEvent(ss);

       System.out.println("Enter venue Of the Second Event: ");

       ss=br.readLine();

       obj2.setVenue(ss);

       System.out.println("Enter Date Of the Second Event(MM/dd/yyyy):");

       ss=br.readLine();

       obj2.setDate(ss);

       System.out.println("Enter duration Of the Second Event: ");

       ss=br.readLine();

       time=Integer.parseInt(ss);

       obj2.setDuration(time);

      

           System.out.println("""+obj1.getEvent()+"" event will take place on "+format.format(obj1.getDate())+" for "+obj1.getDuration()+" hours in "+obj1.getVenue());

          

           System.out.println("""+obj2.getEvent()+"" event will take place on "+format.format(obj2.getDate())+" for "+obj2.getDuration()+" hours in fir"+obj2.getVenue());

      

      

   }

  

  

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote