[Question 4] ICSE 2014 Computer Application Solved - movieMagic.

Question 4.
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)         movieMagic()              Default constructor to initialize numeric data members to 0 and String data member to “”.
(ii)        void accept()               To input and store year, title and rating.
(iii)       void display()              To display the title of a movie and a message based on the rating as per the table below.
RatingMessage to be displayed
0.0 to 2.0Flop
2.1 to 3.4Semi-hit
3.5 to 4.5Hit
4.6 to 5.0Super Hit

Write a main method to create an object of the class and call the above member methods.


SOURCE CODE


import java.io.*;
import java.util.*;
public class movieMagic
{
    static int year;
    static String title;
    static float rating;
    movieMagic()
    {
        year=0;
        rating=0;
        title="";
    }

    public static void accept()
    {
        Scanner sc=new Scanner(System.in);
        System.out.print("Input the year        :");
        year=sc.nextInt();
        System.out.print("Input the title       :");
        title=sc.next();
        System.out.print("Input the rating      :");
        rating=sc.nextFloat();
    }

    public static void display()
    {
        System.out.println(".........OUTPUT........");
        System.out.println("Title of movie      :"+title);
        if((rating>=0.0) && ((rating)<=2.0))
            System.out.println("Movie "+title+" is Flop");
        else if((rating>=2.1) &&(rating<=3.4))
            System.out.println("Movie "+title+" is Semi-hit");
        else if((rating>=3.5) && ((rating)<=4.5))
            System.out.println("Movie "+title+" is Hit");
        else if((rating>=4.6) && ((rating)<=5.0))
            System.out.println("Movie "+title+" is Super Hit");
    }

    public static void main(String args[])throws IOException
    {
        movieMagic obj=new movieMagic();
        obj.accept();
        obj.display();
    }
}


click here to Download

OUTPUT




If you have any question then leave a comment below I will do my best to answer that question.

Comments

Post a Comment

Popular posts from this blog

Pattern of your own name.

[Question 3] ISC 2017 Computer Practical Paper Solved – Caesar Cipher.