如何绘制不完整的模式?

h5qlskok  于 2021-07-12  发布在  Java
关注(0)|答案(0)|浏览(189)

这是我的第一个项目。在选定座位的情况下,第二个电影院放映室模式出现问题。前两个int取房间大小,第二对选择座位,我们需要为每个int绘制图案。第二个没有按预期打印。在“if”语句中可能没有足够的语句。

Scanner scan = new Scanner(System.in);
         // Write your code here
         System.out.println("Enter the number of rows:");
         int rows = scan.nextInt();
         System.out.println("Enter the number of seats in each row:");
         int seats = scan.nextInt();
         int income = 0;
         if (rows * seats <= 60) {
             //income = multiply(rows,seats);
             income = 10;
         }
         else{
             int front = rows/2;
             int back = rows-front;
             //front = multiply(seats,front)*10;
             //back = multiply(seats,back)*8;
             income = 8;
             //front + back;
         }
         System.out.println("Cinema:");
         for (int i = 0; i <= rows; i++) {
             for (int j = 0; j <= seats; j++) {
                 if (i == 0 && j == 0) {
                     System.out.print("  ");
                 } else if (j == 0) {
                     System.out.print(i+" ");
                 } else if (i == 0) {
                     System.out.print(j+" ");
                 } else {
                     System.out.print("S ");
                 }

             }
             System.out.println();
         }
         System.out.println("Enter a row number:");
         int rows2 = scan.nextInt();
         System.out.println("Enter a seat number in that row");
         int seats2 = scan.nextInt();
         System.out.println("Total price:");
         System.out.println("$" + income);
         System.out.println();
         System.out.println("Cinema:");
         for (int i = 0; i <= seats; i++) {
             for (int j = 0; j <= rows; j++) {
                 if (i == 0 && j == 0) {
                     System.out.print("  ");
                 } else if (j == 0) {
                     System.out.print(i+" ");
                 } else if (i == 0) {
                     System.out.print(j+" ");
                 }
                 else if(i==rows2 && j==seats2) {
                     System.out.println("B");
                 }
                 else{
                     System.out.print("S ");
                 }

             }
             System.out.println();
         }

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题