4 Replies Latest reply: Mar 23, 2007 6:05 PM by 807599 RSS

    Where to make changes in the code  from Boolean to Y/N ?

      im kinda new to java . I did this code with help of my friends but we stuck because we were using Boolean insted Y/N could somebody help me to correct problem.

      any help will be much appreciated

      Write a program that continues to accept a movie name (a max
      of 30 characters), its ticketing capacity, and the number of the tickets sold
      until the user indicates to stop. The program should display the column
      headings given below, the movie name, ticketing capacity, number of tickets
      sold, and number of seats available.

      Sample Input and Output:
      Enter a movie name: Blood Diamond
      Enter its ticketing capacity: 500
      Enter number of the tickets sold: 492

      Additional data (Y/N)? Y

      Enter a movie name: Shooter
      Enter its ticketing capacity: 600
      Enter number of the tickets sold: 600

      Additional data (Y/N)? N

      Movie/Capacity/Tickets Sold/Seats Available
      Blood Diamond/500/492/8

      First file (code):
      import java.util.Scanner;
      public class Movies {
           final static int MAXM=50;
            * @param args
           public static void main(String[] args) {
                Movie[] allM = new Movie[50];
                Scanner in = new Scanner(System.in);
                int num = 0;
                String name;
                int tc, ts;
                boolean bn;
                Movie obj;
                for (int i=0; i<MAXM; i++){
                     System.out.println("enter movie: ");
                     name = in.next();
                     System.out.println("enter ticket cap: ");
                     tc = in.nextInt();
                     System.out.println("enter ticketsold: ");
                     ts = in.nextInt();
                     obj = new Movie(name, tc, ts);
                     allM[i] = obj;
                     System.out.println("true/false: ");
                     bn = in.nextBoolean();
                     if (!bn) break;
                int sa;
                for (int i=0; i<num; i++){
                     obj = allM;
                     name = obj.getName();
                     tc = obj.getTicketCap();
                     ts = obj.getTicketSold();
                     sa = obj.getSeats();
                     System.out.println(name + " " + tc ts sa);     



      Second File(code)
      import sun.security.krb5.internal.Ticket;
      public class Movie {
           String name;
           int ticketCap;
           int ticketSold;
           public Movie(String name, int cap, int sold) {
                // TODO Auto-generated constructor stub
                this.name = name;
                ticketCap = cap;
                ticketSold = sold;
           public String getName() {
                return name;
           public void setName(String name) {
                this.name = name;
           public int getTicketCap() {
                return ticketCap;
           public void setTicketCap(int ticketCap) {
                this.ticketCap = ticketCap;
           public int getTicketSold() {
                return ticketSold;
           public void setTicketSold(int ticketSold) {
                this.ticketSold = ticketSold;
           public int getSeats() {
                // TODO Auto-generated method stub
                return ticketCap - ticketSold;