Advertisement
saykotislam

201-15-13993_2b

Apr 8th, 2021
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. package lab.pkg4;
  2. import java.util.Scanner;
  3.  
  4. class Movie{
  5.     String title, studio,rating;
  6.         Movie(String title,String studio,String rating){
  7.         this.title=title;
  8.         this.studio=studio;
  9.         this.rating=rating;
  10.     }
  11.      
  12.     Movie(String title,String studio){
  13.         this.title=title;
  14.         this.studio=studio;
  15.         this.rating="PG";
  16.     }
  17.    
  18.     void dis(){
  19.         System.out.println(title);
  20.         System.out.println(studio);
  21.         System.out.println(rating);
  22.     }      
  23.    
  24. }
  25.  
  26. public class Lab4 {
  27.     public static void main(String[] args) {
  28.          
  29.         String a,b,c;
  30.         Scanner x = new Scanner(System.in);
  31.         a=x.nextLine();
  32.         b=x.nextLine();
  33.         c=x.nextLine();
  34.        
  35.         if(c=="PG"){
  36.         Movie nm=new Movie(a,b);
  37.         nm.dis();}
  38.        
  39.         else{
  40.             Movie ns=new Movie(a,b,c);
  41.         ns.dis();}
  42.  
  43.     }
  44.    
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement