Results 1 to 2 of 2
  1. #1
    Shree123 is offline Member
    Join Date
    Jun 2013
    Posts
    1
    Rep Power
    0

    Default How do u calculate 2 numbers from the method

    public void calculate(int adults, int childern)

    please find the revenue of the adults and childern
    also tell me how to put this on to the console

    full code

    package main;
    import java.util.*;

    public class MovieTheater {

    public double childTicket;
    public double adultTicket;
    public static int CAPACITY = 50;

    public MovieTheater(double childTicket, double adultTicket){
    this.childTicket = (double)childTicket;
    this.adultTicket = (double)adultTicket;
    }

    public MovieTheater(double d,int adultTicket2) {
    }

    public double getPrice(boolean isChild){
    if (isChild)
    return this.childTicket;

    return this.adultTicket;


    }

    public void setPrice(int newPrice, boolean isChild){
    if (isChild)
    this.childTicket = newPrice;
    this.adultTicket = newPrice;
    }
    public void calculate(int adults, int childern){

    }
    public static void main(String[] args){
    Random genRandom = new Random();
    int adults = genRandom.nextInt(MovieTheater.CAPACITY +1);
    int childern = genRandom.nextInt(MovieTheater.CAPACITY + 3);
    MovieTheater theater = new MovieTheater(6.5, 9.15);

    int childPrice = (int)theater.getPrice(true);
    theater.calculate(adults, childern);
    System.out.println(childPrice);



    }


    }

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default Re: How do u calculate 2 numbers from the method

    When posting code you need to place [ code ] before and [ /code ] after (without spaces) to retain formatting. You also need to fully explain what your problem is and ask a specific question. Don't just post your code and expect people to know what is wrong and fix it for you.

Similar Threads

  1. Replies: 16
    Last Post: 02-28-2013, 08:59 PM
  2. Replies: 3
    Last Post: 04-18-2012, 03:10 AM
  3. Replies: 3
    Last Post: 06-30-2011, 10:01 PM
  4. Program in Java To calculate GCD of n numbers.?
    By ankitsinghal_89 in forum New To Java
    Replies: 4
    Last Post: 02-15-2011, 10:23 AM
  5. Replies: 2
    Last Post: 10-24-2010, 05:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •