Define a class named movieMagic with the following description:
Instance variables/data members:
int year : to store the year of release of a movie
String title : to store the title of the movie
float rating : to store the popularity rating of the movie (minimum rating=0.0 and maximum rating=5.0)
Member methods :
(i) Parameterised constructor to store year, title and rating.
(ii) Default constructor to initialize numeric data members to 0 and String data member to ””
(iii) void display() :To display the title of a movie and a message based on the rating as per the table below.
Rating Message to be displayed
0.0 to 2.0 Flop
2.1 to 3.4 Semi-hit
3.5 to 4.5 Hit
4.6 to 5.0 Super Hit
Write a main method to create an object of the class and call the above member methods
public class RailwayTicket
{
String name ;
String coach ;
long mobNo ;
int amt ;
int totalAmt ;
public RailwayTicket( String na, String co, long mo,int am)
{
name = na ;
coach = co;
mobNo = mo ;
amt = am ;
}
public void update()
{
if(coach.equals("First _AC"))
totalAmt = amt+700;
else if (coach.equals("Second AC"))
totalAmt = amt+500;
else if (coach.equals("Third_AC"))
totalAmt = amt+250;
else
totalAmt = amt;
}
public void display()
{
System.out.println(" name: "+name);
System.out.println(" coach : "+coach);
System.out.println(" mobNo: "+mobNo);
System.out.println(" amount : "+amt);
System.out.println(" Totalamount : "+totalAmt);
}
public static void main()
{
RailwayTicket t1 = new RailwayTicket("XXXXX XX", "First _AC" ,64456387, 1200);
t1.update();
t1.display();
}
}