Question

In: Computer Science

Create a mobile application using Android studio, for cinema tickets reservation. The application will be used...

Create a mobile application using Android studio, for cinema tickets reservation. The application will be used by the customers to book cinema tickets. Only users of 15 years old and above are allowed to book cinema tickets for a particular film. The user can book more than one ticket where ticket prices vary between 20 and 50 AED. Your app contains tree Activities. The first activity is a launching activity containing a logo and a button start. When the user press the “Start” button the second activity will appear. The second activity is composed of three Editexts and a button; the name of the user, the user age, and the movie title the button “Reserve” is used to move to the third activity. In the third activity contains a TextView displaying the user name and the movie title, two EditTexts : Price of a ticket and the number of tickets, a button “Calculate Total” used to calculate and to confirm the reservation. First activity: 1. There should be an ImageView to display the logo of the app (Choose any icon). 2. There should be a button “Start”, when the user press this button he should be able to move to the second activity. Second activity: 1. There should be an Editext field for user to enter his/her name; this Editext must not be left empty. 2. There should be an Editext field for user to enter a valid value of his/her age. Appropriate keyboard must be displayed accordingly for the user input. The user age must be 15 and above. The Editext field relative to the user age must not be left empty. 3. There should be an Editext field for user to enter the movie title. For example Avatar, Matrix, Batman, etc. The EdiText field relative to the movie title must not be left empty. 4. There should be a button field “Reserve” for user to move to the third activity. User should be able to pass the user name and the movie title from the second activity to the third activity, which will be displayed as a textbox on the top of the third activity. Third activity: 5. There should be an EditText field for user to enter the price of a single ticket. Ticket prices vary between 20 and 50 AED, this Editext field must not be left empty. 6. User should be able to enter in an EditText how many tickets he/she is booking. Appropriate keyboard must be displayed accordingly for the user input. The user can reserve minimum 1 and maximum 10 tickets at a time.

Solutions

Expert Solution

(First Activity)

Step 1- Add image and a start button to first activity

Step 2- Add functionality to the start button (move to next activity on clicking)

(Second Activity)

Step 3- Add edit texts to take input and a button to proceed to next activity

Step 4- Add checks to the edit text fields and add functionality to reserve button to move to next activity. Also, save the data of edit texts to display them in next activity.

(Third Activity)

Step 5- Add the required text views and edit texts and apply checks on them. Lastly add functionality to calculate button

Here is the complete code with comments for this task-

MainActivity.xml

<LinearLayout>
....
<ImageView
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:layout_gravity="center"
    android:layout_marginTop="50dp"
    android:src="@drawable/logo"/>

    <Button
        android:id="@+id/start"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Start"
        android:layout_gravity="center"
        android:layout_marginTop="70dp"
        android:backgroundTint="@color/teal_200" />

</LinearLayout>

SecondActivity.xml


<LinearLayout
   ...

    <EditText
        android:id="@+id/et_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="Enter Name"
        android:layout_gravity="center"
        android:layout_marginTop="50dp"
        />

    <EditText
        android:id="@+id/et_age"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="Enter Age"
        android:layout_gravity="center"
        android:layout_marginTop="50dp"
        android:inputType="number"/>

    <EditText
        android:id="@+id/et_movie"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="Enter Movie Title"
        android:layout_gravity="center"
        android:layout_marginTop="50dp"/>

    <Button
        android:id="@+id/reserve"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:backgroundTint="@color/teal_200"
        android:layout_gravity="center"
        android:text="RESERVE"
        android:layout_marginTop="100dp" />

</LinearLayout>

ThirdActivity.xml

<LinearLayout 
   ...

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="20dp"
        android:textSize="20dp"
        android:text="Name: "
        android:textColor="@color/black"/>
    <TextView
        android:id="@+id/tv_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="20dp"
        android:textSize="20dp"
        android:textColor="@color/black"/>
</LinearLayout>


    <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="20dp"
        android:textSize="20dp"
        android:text="Movie: "
        android:textColor="@color/black"/>
    <TextView
        android:id="@+id/tv_movie"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_margin="20dp"
        android:textSize="20dp"
        android:textColor="@color/black"/>
    </LinearLayout>

    <EditText
        android:id="@+id/et_price"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:hint="Enter price of one ticket"
        android:inputType="number"
        android:layout_margin="20dp"/>

    <EditText
        android:id="@+id/et_tickets"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:hint="Enter number of tickets to book"
        android:inputType="number"
        android:layout_margin="20dp"/>

    <Button
        android:id="@+id/calculate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:backgroundTint="@color/teal_200"
        android:text="Calculate Total Amount"
        android:layout_gravity="center"
        android:layout_marginTop="100dp"/>

    <TextView
        android:id="@+id/total"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="30dp"
        android:text="Click calculate to view total price here"/>




</LinearLayout>

MainActivity.java

package com.example.cinema;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity {
    Button start;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        start=findViewById(R.id.start);
        start.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //on click of button, user goes to second activity
                Intent intent=new Intent(MainActivity.this,SecondActivity.class);          
                startActivity(intent);
            }
        });

    }

}

SecondActivity.java

package com.example.cinema;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class SecondActivity extends AppCompatActivity {
EditText name, age, movie;
Button reserve;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
        name=findViewById(R.id.et_name);
        age=findViewById(R.id.et_age);
        movie=findViewById(R.id.et_movie);
        reserve=findViewById(R.id.reserve);
        reserve.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String strName=name.getText().toString();
                String strAge=age.getText().toString();
                String strMovie=movie.getText().toString();

                if(strName.equalsIgnoreCase(""))
                    name.setError("please enter username");//it gives user error msg
                else if(strAge.equals(""))
                    age.setError("please enter age");//it gives user error msg
                if(strMovie.equalsIgnoreCase(""))
                    movie.setError("please enter movie");//it gives user error msg
                if(Integer.parseInt(strAge)<15)
                    age.setError("age should be 15 or above");
                else{
                        String passname = name.getText().toString().trim();
                        String passmovie = movie.getText().toString().trim();
                        Bundle bundle = new Bundle();
                        bundle.putString("name", passname);
                        bundle.putString("age", passmovie);
                        Intent intent = new Intent(SecondActivity.this, ThirdActivity.class);
                        intent.putExtras(bundle);
                        startActivity(intent);
                    }
                }
        });

    }

}

ThirdActivity.java

package com.example.cinema;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class ThirdActivity extends AppCompatActivity {
TextView name, movie;
EditText price, tickets;
Button calculate;
TextView total;
int tot;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_third);
        price=findViewById(R.id.et_price);
        tickets=findViewById(R.id.et_tickets);
        calculate=findViewById(R.id.calculate);
        total=findViewById(R.id.total);

        Bundle bundle = getIntent().getExtras();
        if (bundle!= null) {
            String name = bundle.getString("name");
            String age = bundle.getString("age");
            TextView tvName = findViewById(R.id.tv_name);
            TextView tvMovie = findViewById(R.id.tv_movie);
            tvName.setText(name);
            tvMovie.setText(age);

    }

        calculate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String p=price.getText().toString();
                String t=tickets.getText().toString();
                int pr=Integer.parseInt(p);
                int ti=Integer.parseInt(t);
                Log.d("TAG",p+" "+t+" "+pr+" "+ti+" ");
                if(p.equals(""))
                    price.setError("can't be empty");
                if(t.equals(""))
                    tickets.setError("can't be empty");
                if(pr<20||pr>50)
                    price.setError("price should be entered between 20 and 50 EAD");
                if((ti>10))
                    tickets.setError("Can't book more than 10 tickets");
                else {
                    tot = pr * ti;
                    total.setText(Integer.toString(tot));
                }

            }
        });
}
}

I hope the above code fulfills all the requirements. If something is missing, please let me know in comments. I would solve the queries too.


Related Solutions

Android Studio. Java. Please create an application that -> An activity that allows user to enter...
Android Studio. Java. Please create an application that -> An activity that allows user to enter name, gender, date of birth, state of residence (selected from a pre-defined list: CA, AZ, NV, OR), email address and favorite website. This activity has a button "Show Data" that displays detail entered
the code base you will be working with involves an Android application. (Android Studio) application name...
the code base you will be working with involves an Android application. (Android Studio) application name " SharingApp" In the application’s current state: A user of the app is able to create and edit a profile with a unique username and an email address. A user of the app is able to login and logout. An owner is able to record the items they own and wish to share. A bidder is able to place bids on items they wish...
Create a Scorekeeper app in android studio by using java language - Layouts | Widgets Create...
Create a Scorekeeper app in android studio by using java language - Layouts | Widgets Create the layout for your score keeping app. The app should have: Two team names (TextViews) Two scores (TextViews) Buttons to increase/ decrease the scores An amount to change the score by (RadioButtons) You must have at least two score options The scores can be changed by anything you want American football: 1, 2, 3, 6 Basketball: 1, 2, 3 Freestyle wrestling: 1, 2, 3,...
Throughout the course, you have been exposed to a number of technologies that can be utilized in order to create an immersive Android mobile application.
In Android Studio:Throughout the course, you have been exposed to a number of technologies that can be utilized in order to create an immersive Android mobile application. For your Portfolio Project, you will identify a prospective idea for development as an Android mobile application. You will create the interface for the application and identify features for the application. You do not need to full implement the application, but instead you should provide a 4-5 page (not including title and reference...
IN ANDROID STUDIO, you will create a mortgage calculator appthat allows the user to enter...
IN ANDROID STUDIO, you will create a mortgage calculator app that allows the user to enter a purchase price, down-payment amount, and an interest rate.Based on these values, the app should calculate the loan amount (purchase price minus down payment) and display the monthly payment for 10, 20, and 30-year loans.Allow the user to select a custom loan duration (in years) by using a SeekBar and display the monthly payment for that custom loan duration.Assignment deliverables (all in a ZIP...
android studio Begin a new app and create a Java class for products with data: productName,...
android studio Begin a new app and create a Java class for products with data: productName, productCode and price and use a file of objects to store product data and read back and display on screen. Do this by creating a simple form using EditTexts, buttons or ActionBar items and display output using an Alert.
use android studio or MIT inventor Create a Presidents Quiz App for your project with the...
use android studio or MIT inventor Create a Presidents Quiz App for your project with the following requirements: You must have images Buttons Label Conditional Statement Homepage with instructions Sound (music, buzzer, etc.) - Ensure you are using the correct layout: Gravity(Android Studio), Horizontal or Vertical Arrangement (MIT). - 40POINTS Points System (indicating how many answers they got wrong/correct). 20POINT 1-2 questions per President (45+ questions)
Create any IOS mobile application using swift that can do the following A user should be...
Create any IOS mobile application using swift that can do the following A user should be able to see all uncompleted tasks in a UITableView • A user should be able to create new tasks • A user should be able to edit a task • A user should be able to mark a task as complete • A user should be able to see all completed tasks in a UITableView • A user should be able to close and...
Railway Reservation System is a system used for booking railway tickets over the Internet. Any Customer...
Railway Reservation System is a system used for booking railway tickets over the Internet. Any Customer can book tickets for different trains. The Customer can book a ticket only if it is available. Thus, he first checks the availability of tickets, and then if the tickets are available he books the tickets after filling details in a form. The Customer can print the form when booking a ticket. Note that to book a ticket the customer has to checkout by...
List the Marketing Objectives for a newly design Samsung model Android based mobile phone using the...
List the Marketing Objectives for a newly design Samsung model Android based mobile phone using the SMART criteria. Create a mission and vision statement
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT