🔒 Closed C++ cinema ticketing system

Status
Not open for further replies.
and by the way. Iask mo maam mo kung pwede mo palitan yang scanf printf. Ang hirap. Hahaha! Pang C yun, hindi C++. Daming conversion dapat gawin.
 
Patingin ng code. Mas dadali ang usapan natin. :)
Nakakahiya sir pero gusto ko po kasi matuto kaya heto po yung gawa ko este gawa nyo pala pinalitan ko lang po kasi yung syntax ng gawa nyo sir java lang kasi alam ko po programming language hirap pa nga po eh kaya nag aaral po ako at tumitingin nga mga tuts dito pag pasensyahan nyo na sir alam ko mali to pinag gagawa ko.


Patingin ng code. Mas dadali ang usapan natin. :)
public class CinemaTickitingMachine{

static Scanner userInput = new Scanner(System.in);
static int cinemaInput;
static String movieInput;
static String timeInput;
static String seatInput;
static boolean successPicking = false;
static float total;
static String currentCinemaIndex;
static String cinema [][] = new String [][] {

{"Cinema 1", "A", "Avengers Infinity War [PG]", "200", "10:30am - 12:30pm", "12:30pm - 2:30pm"},
{"Cinema 1", "B", "Ant Man [PG]", "230", "2:30pm - 4:30pm", "4:30pm - 6:30pm"},
{"Cinema 1", "C", "Rampage [PG]", "250", "6:30pm - 8:30pm", "8:30pm - 10:30pm"},
{"Cinema 2", "A", "The How's of Us [G]", "210", "10:30am - 12:30pm", "12:30pm - 2:30pm"},
{"Cinema 2", "B", "How I Met Your Mother [PG]", "220", "2:30pm - 4:30pm", "4:30pm - 6:30pm"},
{"Cinema 2", "C", "Fifty Shades [SPG]", "215", "6:30pm - 8:30pm", "8:30pm - 10:30pm"},
{"Cinema 3", "A", "The Nun [SPG]", "220", "10:30am - 12:30pm", "12:30pm - 2:30pm"},
{"Cinema 3", "B", "Anabelle [SPG]", "225", "2:30pm - 4:30pm", "4:30pm - 6:30pm"},
{"Cinema 3", "C", "The Purge [SPG]", "190", "6:30pm - 8:30pm", "8:30pm - 10:30pm"}

};


public static void main (String [] args){

displayMenu();
pickTheCinemaAndMovie();
}

static void displayMenu(){

System.out.println("<<<<<<[Welcome to World Cinema]>>>>>>\n");
System.out.println("Cinema List:\n");
System.out.println(cinema[0][0] + ":\n");
currentCinemaIndex = cinema[0][0];

//Show the môviês in each cinema
for(int i = 0; i < 9; i++)
{
if(currentCinemaIndex != cinema[0])
{
currentCinemaIndex = cinema[0];
System.out.println("======================================\n");
System.out.println(cinema[0] + ":\n");
}

System.out.println( "[" + cinema[1] + "] " + cinema[2] + "\n");
}

//Pick what cinema
System.out.println( "\n\nSelect cinema [1|2|3]: ");
cinemaInput = userInput.nextInt();
cinemaInput = + cinemaInput;

//Pick what môviê
System.out.println( "Select what môviê [A|B|C]: ");
movieInput = userInput.next();

System.out.println( "======================================\n");
System.out.println( "Selected:\n\n");

}
static void pickTheCinemaAndMovie(){
//Search the picked cinema and môviê then output in the screen
for(int i = 0; i < 9; i++)
{
if(cinema[0] + cinemaInput == userInput.next() && cinema[0] == movieInput)
{
System.out.println( cinema[2] + "\n");
System.out.println("Price: P " + cinema[3] + "\n");
System.out.println( "Time Available: \n");
System.out.println("[1]" + cinema[4] + "\n");
System.out.println("[2]" + cinema[5] + "\n");
System.out.println("[3]" + "CANCEL\n\n");

}
}
}
}
 
Nakakahiya sir pero gusto ko po kasi matuto kaya heto po yung gawa ko este gawa nyo pala pinalitan ko lang po kasi yung syntax ng gawa nyo sir java lang kasi alam ko po programming language hirap pa nga po eh kaya nag aaral po ako at tumitingin nga mga tuts dito pag pasensyahan nyo na sir alam ko mali to pinag gagawa ko.



public class CinemaTickitingMachine{

static Scanner userInput = new Scanner(System.in);
static int cinemaInput;
static String môviêInput;
static String timeInput;
static String seatInput;
static boolean successPicking = false;
static float total;
static String currentCinemaIndex;
static String cinema [][] = new String [][] {

{"Cinema 1", "A", "Avengers Infinity War [PG]", "200", "10:30am - 12:30pm", "12:30pm - 2:30pm"},
{"Cinema 1", "B", "Ant Man [PG]", "230", "2:30pm - 4:30pm", "4:30pm - 6:30pm"},
{"Cinema 1", "C", "Rampage [PG]", "250", "6:30pm - 8:30pm", "8:30pm - 10:30pm"},
{"Cinema 2", "A", "The How's of Us [G]", "210", "10:30am - 12:30pm", "12:30pm - 2:30pm"},
{"Cinema 2", "B", "How I Met Your Mother [PG]", "220", "2:30pm - 4:30pm", "4:30pm - 6:30pm"},
{"Cinema 2", "C", "Fifty Shades [SPG]", "215", "6:30pm - 8:30pm", "8:30pm - 10:30pm"},
{"Cinema 3", "A", "The Nun [SPG]", "220", "10:30am - 12:30pm", "12:30pm - 2:30pm"},
{"Cinema 3", "B", "Anabelle [SPG]", "225", "2:30pm - 4:30pm", "4:30pm - 6:30pm"},
{"Cinema 3", "C", "The Purge [SPG]", "190", "6:30pm - 8:30pm", "8:30pm - 10:30pm"}

};


public static void main (String [] args){

displayMenu();
pickTheCinemaAndmôviê();
}

static void displayMenu(){

System.out.println("<<<<<<[Welcome to World Cinema]>>>>>>\n");
System.out.println("Cinema List:\n");
System.out.println(cinema[0][0] + ":\n");
currentCinemaIndex = cinema[0][0];

//Show the môviês in each cinema
for(int i = 0; i < 9; i++)
{
if(currentCinemaIndex != cinema[0])
{
currentCinemaIndex = cinema[0];
System.out.println("======================================\n");
System.out.println(cinema[0] + ":\n");
}

System.out.println( "[" + cinema[1] + "] " + cinema[2] + "\n");
}

//Pick what cinema
System.out.println( "\n\nSelect cinema [1|2|3]: ");
cinemaInput = userInput.nextInt();
cinemaInput = + cinemaInput;

//Pick what môviê
System.out.println( "Select what môviê [A|B|C]: ");
môviêInput = userInput.next();

System.out.println( "======================================\n");
System.out.println( "Selected:\n\n");

}
static void pickTheCinemaAndmôviê(){
//Search the picked cinema and môviê then output in the screen
for(int i = 0; i < 9; i++)
{
if(cinema[0] + cinemaInput == userInput.next() && cinema[0] == môviêInput)
{
System.out.println( cinema[2] + "\n");
System.out.println("Price: P " + cinema[3] + "\n");
System.out.println( "Time Available: \n");
System.out.println("[1]" + cinema[4] + "\n");
System.out.println("[2]" + cinema[5] + "\n");
System.out.println("[3]" + "CANCEL\n\n");

}
}
}
}
Pwede eedit mo yung reply mo? :) Click mo yung more option tapos ilagay mo sa code tag. PAra madali mabasa. Yung "+" sign dun. Nandun yung code tag.
Uy okay lang. Better nga yan, one way to learn din kasi yan. Looking at program tapos applying to make it as your own.
 
Nakakahiya sir pero gusto ko po kasi matuto kaya heto po yung gawa ko este gawa nyo pala pinalitan ko lang po kasi yung syntax ng gawa nyo sir java lang kasi alam ko po programming language hirap pa nga po eh kaya nag aaral po ako at tumitingin nga mga tuts dito pag pasensyahan nyo na sir alam ko mali to pinag gagawa ko.

Code:
public class CinemaTickitingMachine{
 
    static Scanner userInput = new Scanner(System.in);
    static int cinemaInput;
    static String môviêInput;
    static String timeInput;
    static String seatInput;
    static boolean successPicking = false;
    static float total;
    static String currentCinemaIndex;
    static String cinema [][] = new String [][] {
 
        {"Cinema 1", "A", "Avengers Infinity War [PG]", "200", "10:30am - 12:30pm", "12:30pm - 2:30pm"},
        {"Cinema 1", "B", "Ant Man [PG]", "230", "2:30pm - 4:30pm", "4:30pm - 6:30pm"},
        {"Cinema 1", "C", "Rampage [PG]", "250", "6:30pm - 8:30pm", "8:30pm - 10:30pm"},
        {"Cinema 2", "A", "The How's of Us [G]", "210", "10:30am - 12:30pm", "12:30pm - 2:30pm"},
        {"Cinema 2", "B", "How I Met Your Mother [PG]", "220", "2:30pm - 4:30pm", "4:30pm - 6:30pm"},
        {"Cinema 2", "C", "Fifty Shades [SPG]", "215", "6:30pm - 8:30pm", "8:30pm - 10:30pm"},
        {"Cinema 3", "A", "The Nun [SPG]", "220", "10:30am - 12:30pm", "12:30pm - 2:30pm"},
        {"Cinema 3", "B", "Anabelle [SPG]", "225", "2:30pm - 4:30pm", "4:30pm - 6:30pm"},
        {"Cinema 3", "C", "The Purge [SPG]", "190", "6:30pm - 8:30pm", "8:30pm - 10:30pm"}
 
    };
 
 
    public static void main (String [] args){
 
        displayMenu();
        pickTheCinemaAndmôviê();
    }

    static void displayMenu(){
 
        System.out.println("<<<<<<[Welcome to World Cinema]>>>>>>\n");
        System.out.println("Cinema List:\n");
        System.out.println(cinema[0][0] + ":\n");
        currentCinemaIndex = cinema[0][0];

        //Show the môviês in each cinema
        for(int i = 0; i < 9; i++)
        {
            if(currentCinemaIndex != cinema[0])
            {
                currentCinemaIndex = cinema[0];
                System.out.println("======================================\n");
                System.out.println(cinema[0] + ":\n");
            }

            System.out.println( "[" + cinema[1] + "] " + cinema[2] + "\n");
        }
 
        //Pick what cinema
        System.out.println( "\n\nSelect cinema [1|2|3]: ");
        cinemaInput = userInput.nextInt();
        cinemaInput = + cinemaInput;
 
        //Pick what môviê
        System.out.println( "Select what môviê [A|B|C]: ");
        môviêInput = userInput.next();

        System.out.println( "======================================\n");
        System.out.println( "Selected:\n\n");
 
    }
        static void pickTheCinemaAndmôviê(){
        //Search the picked cinema and môviê then output in the screen
        for(int i = 0; i < 9; i++)
        {
            if(cinema[0] + cinemaInput == userInput.next() && cinema[0] == môviêInput)
            {
                System.out.println( cinema[2] + "\n");
                System.out.println("Price: P " + cinema[3] + "\n");
                System.out.println( "Time Available: \n");
                System.out.println("[1]" + cinema[4] + "\n");
                System.out.println("[2]" + cinema[5] + "\n");
                System.out.println("[3]" + "CANCEL\n\n");
         
            }
        }
    }
}
1. Icheck mo yung laman nung movieInput at cinemaInput.
Debug mo. I print mo dapat "Cinema 1" example labas nun for cinemaInput at "A, B, C" naman sa movieInput.
Kasi mali nalalagay dun sa code mo. Kaya hindi papasok sa if statement. sa pickTheCinemaAndMovie
2. Kulang yung code. After ng last line na ma "CANCEL" Input ng selected time at I paprocess na nun yung nahanap na movie at ilalabas yun with calculated total. Wala ka nung last part ng program.
3. LAhat ng input dapat string lang. int yung cinemaInput mo.
 
1. Icheck mo yung laman nung môviêInput at cinemaInput.
Debug mo. I print mo dapat "Cinema 1" example labas nun for cinemaInput at "A, B, C" naman sa môviêInput.
Kasi mali nalalagay dun sa code mo. Kaya hindi papasok sa if statement. sa pickTheCinemaAndmôviê
2. Kulang yung code. After ng last line na ma "CANCEL" Input ng selected time at I paprocess na nun yung nahanap na môviê at ilalabas yun with calculated total. Wala ka nung last part ng program.
3. LAhat ng input dapat string lang. int yung cinemaInput mo.

import java.util.*;

public class CinemaTickitingMachine{

static String cinemaInput;
static int cinemaIndex = 1;
static String movieInput;
static String timeInput;
static String seatInput;
static boolean successPicking = false;
static float total;
static String currentCinemaIndex;
static Scanner userInput = new Scanner(System.in);

static String cinema [][] = new String [][] {

{"Cinema 1", "A", "Avengers Infinity War [PG]", "200", "10:30am - 12:30pm", "12:30pm - 2:30pm"},
{"Cinema 1", "B", "Ant Man [PG]", "230", "2:30pm - 4:30pm", "4:30pm - 6:30pm"},
{"Cinema 1", "C", "Rampage [PG]", "250", "6:30pm - 8:30pm", "8:30pm - 10:30pm"},
{"Cinema 2", "A", "The How's of Us [G]", "210", "10:30am - 12:30pm", "12:30pm - 2:30pm"},
{"Cinema 2", "B", "How I Met Your Mother [PG]", "220", "2:30pm - 4:30pm", "4:30pm - 6:30pm"},
{"Cinema 2", "C", "Fifty Shades [SPG]", "215", "6:30pm - 8:30pm", "8:30pm - 10:30pm"},
{"Cinema 3", "A", "The Nun [SPG]", "220", "10:30am - 12:30pm", "12:30pm - 2:30pm"},
{"Cinema 3", "B", "Anabelle [SPG]", "225", "2:30pm - 4:30pm", "4:30pm - 6:30pm"},
{"Cinema 3", "C", "The Purge [SPG]", "190", "6:30pm - 8:30pm", "8:30pm - 10:30pm"}

};

public static void main (String [] args){

displayMenu();
pickTheCinemaAndMovie();
}

static void displayMenu(){

System.out.println("<<<<<<[Welcome to World Cinema]>>>>>>\n");
System.out.println("Cinema List:\n");
System.out.println(cinema[0][0] + ":\n");
currentCinemaIndex = cinema[0][0];

//Show the môviês in each cinema
for(int i = 0; i < 9; i++)
{
if(currentCinemaIndex != cinema[0])
{
currentCinemaIndex = cinema[0];
System.out.println("======================================\n");
System.out.println(cinema[0] + ":\n");
}

System.out.println( "[" + cinema[1] + "] " + cinema[2] + "\n");
}

//Pick what cinema
System.out.println( "\n\nSelect cinema [1|2|3]: ");
cinemaInput = userInput.next();
cinemaInput = "Cinema " + cinemaInput;

//Pick what môviê
System.out.println( "Select what môviê [A|B|C]: ");
movieInput = userInput.next();

System.out.println( "======================================\n");
System.out.println( "Selected:\n\n");

}
static void pickTheCinemaAndMovie(){
//Search the picked cinema and môviê then output in the screen
for(int i = 0; i < 9; i++)
{
if(cinema[0] == cinemaInput && cinema[0] == movieInput)
{
System.out.println( cinema[2] + "\n");
System.out.println("Price: P " + cinema[3] + "\n");
System.out.println( "Time Available: \n");
System.out.println("[1]" + cinema[4] + "\n");
System.out.println("[2]" + cinema[5] + "\n");
System.out.println("[3]" + "CANCEL\n\n");

while (true)
{
System.out.println("Select time [1|2]: ");
timeInput = userInput.next();

if(timeInput == "1")
{
timeInput = cinema[4];
successPicking = true;
break;
}
else if (timeInput == "2")
{
timeInput = cinema[5];
successPicking = true;
break;
}
else if (timeInput == "3")
{
//system("cls");
//ibig sabihin po ba ng system("cls");
//ganito po ba yan sa Java?

System.exit(0);
break;
}
else
{
System.out.println("Invalid input, please try again...");
}
}
if(successPicking)
{
System.out.println("How many seats or tickets: ");
seatInput = userInput.next();

//total = stoi(cinema[3]) * seatInput;
//hindi ko alam kung ano stoi sa c++ sir
//kinomment ko hindi ako kasi alam kung pano ko icocovert sa Java yan.

System.out.println("======================================\n");
System.out.println("môviê\n");
System.out.println(cinema[2] + "\n");
System.out.println("Time: " + timeInput + "\n");
System.out.println("Price: P " + cinema[3] + "\n");
System.out.println("Seats: " + seatInput + "\n");
System.out.println("Total: " + total);
}
else
{
break;
}
}
}
return;
}
}
 
1. Icheck mo yung laman nung môviêInput at cinemaInput.
Debug mo. I print mo dapat "Cinema 1" example labas nun for cinemaInput at "A, B, C" naman sa môviêInput.
Kasi mali nalalagay dun sa code mo. Kaya hindi papasok sa if statement. sa pickTheCinemaAndmôviê
2. Kulang yung code. After ng last line na ma "CANCEL" Input ng selected time at I paprocess na nun yung nahanap na môviê at ilalabas yun with calculated total. Wala ka nung last part ng program.
3. LAhat ng input dapat string lang. int yung cinemaInput mo.
Sir na debug na po ako ayaw talaga pumasok sa if kanina ko pa iniisip bakit kaya hindi syan nag tutuloy hanggang selected lang yung na piprint pero na piprint yung pick a cinema saka pick a movie tapus ma piprint yung selected pero walang laman bakit kaya?
 
Sir na debug na po ako ayaw talaga pumasok sa if kanina ko pa iniisip bakit kaya hindi syan nag tutuloy hanggang selected lang yung na piprint pero na piprint yung pick a cinema saka pick a môviê tapus ma piprint yung selected pero walang laman bakit kaya?
Ilagay mo sa tag na
Code:
 program code
Yung code.
 
Sir na debug na po ako ayaw talaga pumasok sa if kanina ko pa iniisip bakit kaya hindi syan nag tutuloy hanggang selected lang yung na piprint pero na piprint yung pick a cinema saka pick a môviê tapus ma piprint yung selected pero walang laman bakit kaya?
instead na == sa if try mo myString.equals(myOtherString)
Bale
Code:
 cinema[i][0].equals(cinemaInput)
Tapos yung isa naman.
 
Sir na debug na po ako ayaw talaga pumasok sa if kanina ko pa iniisip bakit kaya hindi syan nag tutuloy hanggang selected lang yung na piprint pero na piprint yung pick a cinema saka pick a môviê tapus ma piprint yung selected pero walang laman bakit kaya?
Tapos yung sa movieInput sa cinema 1 yun hindi 0, sa loob ng box bracket.
 
Status
Not open for further replies.

About this Thread

  • 30
    Replies
  • 2K
    Views
  • 5
    Participants
Last reply from:
mrHazan

Online now

Members online
575
Guests online
635
Total visitors
1,210

Forum statistics

Threads
2,275,535
Posts
28,963,914
Members
1,232,842
Latest member
Mulgarot
Back
Top