#Need a different solution! IntelliJ Cinema Project

7 messages · Page 1 of 1 (latest)

undone ice
#

My code works for what the assignment is asking of us. It is not the solution it wants and I am at a loss, because I can't progress due to it's finicky behaviour of accepting only certain solutions, or hey maybe I got it all wrong.

I stumbled upon a Learning feature in the IntelliJ IDE and it's got courses to follow and projects to choose from, so I chose the Cinema project to start.

We are asked to read two positive integer numbers from the input: the number of rows and the number of seats in each row. The ticket price is determined by the following rules:

If the total number of seats in the screen room is not more than 60, then the price of each ticket is 10 dollars.
In a larger room, the tickets are 10 dollars for the front half of the rows and 8 dollars for the back half. Please note that the number of rows can be odd, for example, 9 rows. In this case, the first half is the first 4 rows, and the second half is the other 5 rows.

I have posted a picture of the sample output it would like us to achieve, and here is my code:

rocky sigilBOT
#

This post has been reserved for your question.

Hey @undone ice! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

undone ice
#
import java.util.Scanner;

public class Cinema {
    public static void main(String[] args) {

//Declaring and Initializing my Scanner which I am naming sc
        Scanner sc = new Scanner(System.in);

//Declaring my variables and initializing the ticketPrice at 10 which I will modify for back row
        int rows, columns, totalSeats, income, ticketPrice = 10;

//Taking the user input for the number of rows and number of seats in each row (AKA columns)

            System.out.println("Enter the number of rows:");
                rows = sc.nextInt();
            System.out.println("Enter the number of seats in each row:");
                columns = sc.nextInt();

//Initializing totalSeats as the value input by user for the rows * number of columns
            totalSeats = rows * columns;

//If First condition is true, use this formula to calculate and display the income
            if (totalSeats <= 60) {
                income = totalSeats * ticketPrice;
                System.out.println("Total income: \n$" + income);
            }

/*Or else, if the Second condition true, use this formula instead to calculate and display the income.
Calculating total income in theatre with more than 60 people and the discount applied for rows >= 5*/
            else if (totalSeats >= 60 && rows >= 5 && rows < 10) {
                income = (4 * columns * ticketPrice) + ((rows - 4) * (columns) * (ticketPrice - 2));
                System.out.println(
                        "Total income: \n$" + income);
            }
//Finally,  else statement to satisfy the condition of only being able to have 9 rows in this project.
            else
            {
                System.out.println(
                        "We do not have a theatre with that many rows available. Please select a value below 9");
            }
    }
}```
#

Another Screenshot detailing the problem / instructions.

warm jewel
#

and you cannot always assume that you have four front rows. you should be calcualting the front rows by dividing the total rows by 2