Sign in with
Sign up | Sign in
Your question

Problem in java

Last response: in Applications
Share
February 28, 2013 3:34:56 AM

;)  import java.io.*;
public class bro
{
public static void main(string args[])
{
seat [][]
seats=new seat[5][6];
int row, input, how many, count =0;
string name;
string movie="Movie Title:"
+"\n1:Seat"
+"\n2:view seat"
+"\n0:quit";
for (int i=0; i<5; i++)
{
seats[0]=new Seat("1");
seats[1]=new Seat("2");
seats[2]=new Seat("3");
seats[3]=new Seat("4");
seats[4]=new Seat("5");
seats[5]=new Seat("6");
}
{
System.out.println("\n"+movie);
System.out.println("Input (1-2 or 0): ");
input = Integer.parseInt(reader.next());
reader.nextLine();
switch(input)
{
case 1:

if(count == 30)
{
System.out.println("\nThe cinema is fully booked.");
}
else
{
do
{
System.out.print("How many seats would you like to book? ");

howmany = reader.nextInt();
if(howmany>5)
{
System.out.println("The maximum number of seats per booking is 5.");
}
if(howmany<1)
{
System.out.println("The minimum number of seats per booking is 1.");
}
}
while(howmany>5 // howmany<1);
for(int j=0;j<=howmany;j++)
{
printArray(seats);
do
{
System.out.println("Where would person number"+(j+1)+" like to sit?");
do
{
System.out.print("Row: ");
row=reader.nextInt();
//If the user choses a nonexistent row
if(row>5)
{
System.out.println("There are only 5 rows, please choose a new row.");
}
}
while(row>5);
do
{
System.out.print("Seat: ");
name=reader.next();
if(!name.equals("1") && !name.equals("2") && !name.equals("3") && !name.equals("4") && !name.equals("5") && !name.equals("6"))
{
System.out.println("There are only 6 seats per row, please choose a new seat.");
}
}
while(!name.equals("1") && !name.equals("2") && !name.equals("3") &&
!name.equals("4") && !name.equals("5") && !name.equals("6"));
}
while(row>5);
for(int i=0;i<6;i++)
{
if(seats[row-1].getName().equalsIgnoreCase(name))
{
if(seats[row-1].getVisible()==false)
{
System.out.println("\nThat seat is already taken, please select another one.\n");
j--;
}

{
seats[row-1].setVisible(false);
count++;
}
}
}
}
}
break;

case 2:
printArray(seats);
break;

case 0:
System.out.println("Good bye!");
break;

default:
//Informs the user that the input is not valid
System.out.println("Invalid input.");
break;
}
}
while(input != 0);
}
public static void printArray(Seat[][] a)
{
//Prints the rows
System.out.println("-SCREEN-");
for(int i=0;i<5;i++)
{
System.out.print(i+1+" ");
//Prints the seats
for(int j=0;j<6;j++)
{
System.out.print(a[j]);
}
System.out.print(" ");
System.out.println();
}
}
}


need help on this java coding...

More about : problem java

a b L Programming
February 28, 2013 5:03:00 AM

You haven't asked a question. You haven't told is what the program is supposed to do. You haven't told us what error(s) there are. How can we help you?
m
0
l
a b L Programming
February 28, 2013 6:38:34 AM

I don't know about problems in Java but there's certainly a problem here:

  1. int row, input, how many, count =0;
m
0
l
Related resources
February 28, 2013 8:51:39 AM

Ijack said:
You haven't asked a question. You haven't told is what the program is supposed to do. You haven't told us what error(s) there are. How can we help you?



I need to creat a simple java program that is cinema purchasing system.
Movie title, date, time, cinema no. And seat no. Need to be print on the ticket.
This program only need to use appropriate variables, control structure and array.
And the program can be test using assertion.

Can you solve it?
I have creat a java program, can you help me repair the program?
m
0
l
a b L Programming
February 28, 2013 8:56:04 AM

I see your program, but you haven't told us what is wrong.

Does it compile?
What input are you giving it?
What results do you expect?
What results are you getting?

You still haven't told us what your problem is.
m
0
l
February 28, 2013 9:29:31 AM

randomizer said:
I don't know about problems in Java but there's certainly a problem here:

  1. int row, input, how many, count =0;



Can you show me how to fix this problem?
Cause im still new on this java program..
m
0
l
a b L Programming
February 28, 2013 9:33:49 AM

You take out the space in "how many".

As you still haven't told us what your problem is, what is going wrong, whether your program compiles, or much else, I'm going to give up at this point.
m
0
l
February 28, 2013 9:36:40 AM

Ijack said:
I see your program, but you haven't told us what is wrong.

Does it compile?
What input are you giving it?
What results do you expect?
What results are you getting?

You still haven't told us what your problem is.



I have compile my program, but the program got an error..
I don't know how to fixed this error.
The result that I expect is just like cinema purchasing system.
m
0
l
a b L Programming
February 28, 2013 10:10:19 AM

We can't read your mind or your screen. You're going to have to tell us the error and maybe even post a stacktrace (if it's a runtime error). The more details that you can tell us about the problem and what you are trying to do, the better. If you are vague you are going to get vague answers.
m
0
l
February 28, 2013 3:21:43 PM

Ijack said:
You take out the space in "how many".

As you still haven't told us what your problem is, what is going wrong, whether your program compiles, or much else, I'm going to give up at this point.



I have fix the spaces at "howmany".
But when i run, "while(howmany>5 // howmany<1); "
Have an error..
Can you find why?
Please..
m
0
l
a b L Programming
February 28, 2013 7:49:54 PM

I think you meant to use a double pipe ( || ) there, not a double slash. You've commented out the second half of the line.
m
0
l
a b L Programming
February 28, 2013 10:37:13 PM

This looks suspiciously like a homework assignment, and the OP is hoping we'll do all the grunt work for him/her.
m
0
l
a b L Programming
February 28, 2013 10:44:34 PM

It quite likely is given the relatively small amount of code. However, since we still haven't been told the actual error it's very difficult to do the grunt work anyway.
m
0
l
!