Richard_Sekol

project7.5

Nov 15th, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. package chap7;
  2. import java.util.scanner;
  3. public class project75 {
  4. public static void main(String[] args) {
  5.  
  6. int[][] theaterChart = {
  7. { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
  8. { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
  9. { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
  10. { 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 },
  11. { 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 },
  12. { 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 },
  13. { 20, 20, 30, 30, 40, 40, 30, 30, 20, 20 },
  14. { 20, 30, 30, 40, 50, 50, 40, 30, 30, 20 },
  15. { 30, 40, 50, 50, 50, 50, 50, 50, 40, 30 }, };
  16.  
  17. int rows = 10;
  18. int columns = 9;
  19.  
  20. Scanner scan = new Scanner(System.in);
  21.  
  22. System.out.println("Do you want to choose a seat (input s), choose a price (input p) or quit (input q)");
  23. String input = scan.nextLine();
  24. if(input.charAt(0) == 's'){
  25.  
  26. System.out.println("enter a seat to choose. please enter two digits separated without a space.");
  27. System.out.println("the first digit should be btwn 0-8 and the second should be btwn 0-9");
  28. System.out.println("enter the first digit now");
  29. int firstNumber = scan.nextInt();
  30. System.out.println("entire the second digit now");
  31. int secondNumber = scan.nextInt();
  32.  
  33. if(theaterChart[firstNumber][secondNumber] != 0){
  34. System.out.println("this seat is available");
  35. System.out.println("do you want to choose this seat? input y for yes or n for no");
  36. char choice = scan.next().charAt(0);
  37.  
  38. if(choice == 'y'){
  39. theaterChart[firstNumber][secondNumber] = 0;}}}
  40. if(input.charAt(0) == 'p'){
  41. System.out.println("enter either 10, 20, 30, 40, or 50 as your price");
  42. int priceInput = scan.nextInt();
  43. for(int i = 0; i < columns; i++){
  44. for(int j = 0 ; j < rows; j++){
  45. if(theaterChart[i][j] == priceInput){
  46. System.out.println(i + " " + j);}}}}}}
Advertisement
Add Comment
Please, Sign In to add comment