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

Java 1410 second semester ? Download the class Time.java ? Create a new class ca

ID: 3663632 • Letter: J

Question

Java 1410 second semester

? Download the class Time.java

? Create a new class called Concert.java based on the class diagram below

? Create a class called ConcertApp.java .
? This class includes the main method.
? Inside the main method create an instance of Concert. Initialize it with values of your choice. ? Print the newly created concert

***********************************

// Time class

package l02review;

public class Time
{
   private int hours;
   private int minutes;
   private int seconds;

   public Time(int h, int m, int s)
   {
setTime(h, m, s);
   }

   public Time()
   {
   }

   public void setHours(int h)
   {
hours = ((h >= 0 && h < 24) ? h : 0);
   }

   public void setMinutes(int m)
   {
minutes = ((m >= 0 && m < 60) ? m : 0);
   }

   public void setSeconds(int s)
   {
seconds = ((s >= 0 && s < 60) ? s : 0);
   }

   public void setTime(int h, int m, int s)
   {
setHours(h);
setMinutes(m);
setSeconds(s);
   }

   public String toMilitary()
   {
return String.format("%02d:%02d:%02d", hours, minutes, seconds);
   }

   @Override
   public String toString()
   {
return String.format("%d:%02d:%02d %s",
(hours == 0 || hours == 12) ? 12 : hours % 12, minutes,
seconds, (hours < 12) ? "AM" : "PM");
   }

}

Explanation / Answer

package l02review;

public class Concert {
   String name;
   Time startTime;
   Time endTime;
   Concert(String n,Time start,Time end)
   {
       name=n;
       startTime=start;
       endTime=end;
   }  
}

package l02review;

public class ConcertApp {
   public static void main(String str[])
   {
       Time start=new Time(8,30,00);
       Time end=new Time(10,30,00);
       Concert obj=new Concert("Pitbull",start,end);
       System.out.println("Name : "+ obj.name);
       System.out.println("Start Time : "+obj.startTime);
       System.out.println("End Time : "+obj.endTime);
      
   }
}

Result:

Name : Pitbull
Start Time : 8:30:00 AM
End Time : 10:30:00 AM

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