package themovie;
import java.text.*;
public class MovieTester {
public static void main(String args[]) {
Movie m1 = new Movie("Avatar","180 minutes","Sam Worthington","Action");
System.out.println("Name : "+m1.getName());
System.out.println("Duration : "+m1.getDuration());
System.out.println("Hero : "+m1.getHero());
System.out.println("Genre : "+m1.getGenre());
double monthSales = m1.averageMonthlySales(42350,250);
NumberFormat currencyFormat = NumberFormat.getCurrencyInstance();
System.out.println("Average Monthly Sales : "+currencyFormat.format(monthSales));
double Profit = m1.profit(1736927000,516262000);
System.out.println("Profit : "+currencyFormat.format(Profit));
System.out.println(m1.tellAboutSelf());
}
}
package themovie;
public class Movie {
private String name;
private String duration;
private String hero;
private String genre;
public Movie(String name1, String duration1, String hero1, String genre1) {
setName(name1);
setDuration(duration1);
setHero(hero1);
setGenre(genre1);
}
public void setName(String aName) {
name = aName;
}
public void setDuration(String aDuration) {
duration = aDuration;
}
public void setHero(String aHero) {
hero = aHero;
}
public void setGenre(String aGenre) {
genre = aGenre;
}
public String getName() {
return name;
}
public String getDuration() {
return duration;
}
public String getHero() {
return hero;
}
public String getGenre() {
return genre;
}
public double averageMonthlySales(double dailyAvgTickets, double price) {
double avgSales = dailyAvgTickets*price*30;
return avgSales;
}
public double profit(double income, double expenses) {
double p = income-expenses;
return p;
}
public String tellAboutSelf() {
String info = "Movie name is "+getName()+",\nDuration is "+getDuration()+",\nHero is "+getHero()+",\nand Genre is "+getGenre();
return info;
}
}
run:
Profit : Rs.1,220,665,000.00
Movie name is Avatar,
Duration is 180 minutes,
Hero is Sam Worthington,
and Genre is Action