What's new

Closed C++ cinema ticketing system

Status
Not open for further replies.

PHC - MRX

Eternal Poster
Joined
Apr 15, 2015
Posts
770
Reaction
229
Points
285
Age
23
guys baka matulungan nyo ko dito lalo na sa mga batak dyan HAHAHAHA , cinema ticketing system mga paps . eto code ko
cinema 1 palang nagagawan ko e tapos Letter A , Avengers inf. war palang , dko na kase magawa sa ibang movie yung ibang code ...test nyo nalang paps hingi lang me konting tulong

ganon paps sa picture , ung per movie may oras at presyo tapos number ng seats, tapos matototal lahat ng presyo , dko na magawa sa isang movie eh






-----------------------------
#include <stdio.h>
int main()
{
int cinema[10] = {200,230,250,200,230,250};
int cin1, cin2, cin3;
char choice, movies, time, time1, cin, seats;
int M1=200, M2=230, M3=200, M4=250, M5=200, M6=180;
int i;
int total=0;

printf("\t\t\tWelcome to World Cinema");
printf("\nMovie Lists");
printf("\n\nCinema 1");
printf("\n[A]Avengers Infinity War [PG]");
printf("\nAnt Man [PG]");
printf("\n[C]Rampage [PG]");

printf("\n\nCinema 2");
printf("\n[A]The How's of Us [G]");
printf("\nHow I Met Your Mother [PG]");
printf("\n[C]Fifthy Shades [SPG]");

printf("\n\nCinema 3");
printf("\n[A]The Nun [SPG]");
printf("\nAnabelle [SPG]");
printf("\n[C]The Purge [SPG]");

printf("\n\nPlease Select Your Cinema: ");
scanf("%c", &cin);
if(cin == '1' || cin == '1'){
printf("\n[A] Avengers Infinity War");
printf("\n Ant Man");
printf("\n[C] Rampage");
}
printf("\n\nPlease Select Your Movie: ");
scanf("%s", &movies);

if(movies == 'A' || movies == 'a'){
printf("\n[A] Avengers Infinity War [PG]");
printf("\n\nPrice: 200 Php");
printf("\n\nTime:");
printf("\n[1] 10:30am - 12:30pm");
printf("\n[2] 12:30pm - 2:30pm");
}
else if (movies == 'B' || movies == 'b'){
printf("\nAnt Man");
printf("\n\nPrice: 230 Php");
printf("\n\nTime:");
printf("\n[1] 2:30pm - 4:30pm");
printf("\n[2] 4:30pm - 6:30pm");
}

else if (movies == 'C' || movies == 'c'){
printf("\nRampage");
printf("\n\nPrice: 250 Php");
printf("\n\nTime:");
printf("\n[1] 6:30pm - 8:30pm");
printf("\n[2] 8:30pm - 10:30pm");
}

printf("\n\nPlease Select Your Time: [0]/[1]: ");
scanf("%s", &time);

printf("\n\nAvengers Infinity War");
printf("\nPrice: 200 Php");
if(time == '0' || time == '1'){
printf("\nTime: 10:30 am - 12:30pm");
}
else{
printf("\nTime: 12:30pm - 2:30pm");
}
printf("\n\nHow many Seats: ");
scanf("%s", &seats);
if(seats == '2' || seats == '2'){
printf("\n\nMovie");
printf("\nCinema 1");
printf("\nAvengers Infinity War");
printf("\nTime: 10:30 am - 12:30pm");
printf("\nPrice: 200 Php");
printf("\nSeats Taken: 2 ");
printf("\nThe Total is %d", cinema[0] *2);
}
else if(seats == '3' || seats == '3'){
printf("\n\nMovie");
printf("\nCinema 1");
printf("\nAvengers Infinity War");
printf("\nTime: 10:30 am - 12:30pm");
printf("\nPrice: 200 Php");
printf("\nSeats Taken: 3 ");
printf("\nThe Total is: %d", cinema[0] *3);
}
else if(seats == '4' || seats == '4'){
printf("\n\nMovie");
printf("\nCinema 1");
printf("\nAvengers Infinity War");
printf("\nTime: 10:30 am - 12:30pm");
printf("\nPrice: 200 Php");
printf("\nSeats Taken: 4 ");
printf("\nThe Total is %d", cinema[0] *4);
}
else if(seats == '5' || seats == '5'){
printf("\n\nMovie");
printf("\nCinema 1");
printf("\nAvengers Infinity War");
printf("\nTime: 10:30 am - 12:30pm");
printf("\nPrice: 200 Php");
printf("\nSeats Taken: 5 ");
printf("\nThe Total is %d", cinema[0] *5);
}
else if(seats == '6' || seats == '6'){
printf("\n\nMovie");
printf("\nCinema 1");
printf("\nAvengers Infinity War");
printf("\nTime: 10:30 am - 12:30pm");
printf("\nPrice: 200 Php");
printf("\nSeats Taken: 6 ");
printf("\nThe Total is %d", cinema[0] *6);
}
else if(seats == '7' || seats == '7'){
printf("\n\nMovie");
printf("\nCinema 1");
printf("\nAvengers Infinity War");
printf("\nTime: 10:30 am - 12:30pm");
printf("\nPrice: 200 Php");
printf("\nSeats Taken: 7 ");
printf("\nThe Total is %d", cinema[0] *7);
}
else if(seats == '8' || seats == '8'){
printf("\n\nMovie");
printf("\nCinema 1");
printf("\nAvengers Infinity War");
printf("\nTime: 10:30 am - 12:30pm");
printf("\nPrice: 200 Php");
printf("\nSeats Taken: 8 ");
printf("\nThe Total is %d", cinema[0] *8);
}
else if(seats == '9' || seats == '9'){
printf("\n\nMovie");
printf("\nCinema 1");
printf("\nAvengers Infinity War");
printf("\nTime: 10:30 am - 12:30pm");
printf("\nPrice: 200 Php");
printf("\nSeats Taken: 9 ");
printf("\nThe Total is %d", cinema[0] *9);
}
else{
(seats == '10' || seats == '10');
printf("\n\nMovie");
printf("\nCinema 1");
printf("\nAvengers Infinity War");
printf("\nTime: 10:30 am - 12:30pm");
printf("\nPrice: 200 Php");
printf("\nSeats Taken: 10 ");
printf("\nThe Total is %d", cinema[0] *10);
return 0; }

}
 

Attachments

Last edited:
sir may problem ka po sa code nesting
ito op sample

HTML:
printf("\n\nPlease Select Your Cinema: ");
scanf("%c", &cin);
if(cin == '1'){    <------- cinema 1 movies
  printf("\n[A] Avengers Infinity War");
  printf("\n Ant Man");
  printf("\n[C] Rampage");
    
      printf("\n\nPlease Select Your môviê: "); <---------- select movies
      scanf("%s", &môviês);

      if(môviês == 'A' || môviês == 'a'){
      printf("\n[A] Avengers Infinity War [PG]");
      printf("\n\nPrice: 200 Php");
      printf("\n\nTime:");
      printf("\n[1] 10:30am - 12:30pm");
      printf("\n[2] 12:30pm - 2:30pm");
      }
      else if (môviês == 'B' || môviês == 'b'){
      printf("\nAnt Man");
      printf("\n\nPrice: 230 Php");
      printf("\n\nTime:");
      printf("\n[1] 2:30pm - 4:30pm");
      printf("\n[2] 4:30pm - 6:30pm");
      }

      else if (môviês == 'C' || môviês == 'c'){
      printf("\nRampage");
      printf("\n\nPrice: 250 Php");
      printf("\n\nTime:");
      printf("\n[1] 6:30pm - 8:30pm");
      printf("\n[2] 8:30pm - 10:30pm");
      }

}else if(cin == '2'){ <---- cinema 2 movies
  printf("\n[A]The How's of Us [G]");
  printf("\nHow I Met Your Mother [PG]");
  printf("\n[C]Fifthy Shades [SPG]");
}else{
  printf("\nPlease enter valid Cenima");
}
 
To give you an idea na may mas magandang approach para umikli yung code mo and mas easy kung dadagdag ka pa ng movies.
A.PNG B.PNG C.PNG

Sample Outputs:
1.PNG 2.PNG 3.PNG
 

Attachments

To give you an idea na may mas magandang approach para umikli yung code mo and mas easy kung dadagdag ka pa ng môviês.
View attachment 466384 View attachment 466385 View attachment 466386

Sample Outputs:
View attachment 466381 View attachment 466382 View attachment 466383


Ang ayos sir ng code & Output , Kaso sir d pa samin naturo ung cout , puro printf lang kami , pwede po ba pa copy ng code? hehe kung pwede lang sir. para pag aaralan ko then aapply ko sa code ko tia
 
Ang ayos sir ng code & Output , Kaso sir d pa samin naturo ung cout , puro printf lang kami , pwede po ba pa copy ng code? hehe kung pwede lang sir. para pag aaralan ko then aapply ko sa code ko tia
Parehas ang cout saka printf. mas prefer ko lang cout cin sa c++.
Ano muna last topic niyo sa programming?
 
Parehas ang cout saka printf. mas prefer ko lang cout cin sa c++.
Ano muna last topic niyo sa programming?

array po paps. sabi kase ng prof namin gumamit ng for loop then array , eh sa sarili kong nicode paps if else lang at array
 
array po paps. sabi kase ng prof namin gumamit ng for loop then array , eh sa sarili kong nicode paps if else lang at array
multidimenisional array kasi nagamit dyan kailangan mo mapag-aralan yun.


Code:
#include <iostream>

using namespace std;

int main()
{
    string cinema[9][6] =
    {
        {"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"}
    };
  
    int cinemaIndex = 1;
    string cinemaInput;
    string movieInput;
    string timeInput;
    int seatInput;
    bool successPicking = false;
    float total = 0;
  
    cout << "<<<<<<[Welcome to World Cinema]>>>>>>\n";
    cout << "Cinema List:\n";
    cout << "======================================\n";
    cout << cinema[0][0] << ":\n";
    currentCinemaIndex = cinema[0][0];
  
    //Show the movies in each cinema
    for(int i = 0; i < 9; i++)
    {
        if(currentCinemaIndex != cinema[i][0])
        {
            currentCinemaIndex = cinema[i][0];
            cout<< "======================================\n";
            cout<< cinema[i][0] << ":\n";
        }
      
        cout<< "[" << cinema[i][1] << "] " << cinema[i][2] << "\n";
    }
  
    //Pick what cinema
    cout<< "\n\nSelect cinema [1|2|3]: ";
    cin >> cinemaInput;
    cinemaInput = "Cinema " + cinemaInput;
  
    //Pick what movie
    cout<< "Select what movie [A|B|C]: ";
    cin >> movieInput;
  
    cout<< "======================================\n";
    cout<< "Selected:\n\n";
  
    //Search the picked cinema and movie then output in the screen
    for(int i = 0; i < 9; i++)
    {
        if(cinema[i][0] == cinemaInput && cinema[i][1] == movieInput)
        {
            cout<< cinema[i][2] << "\n";
            cout<< "Price: P " << cinema[i][3] << "\n";
            cout<< "Time Available: \n";
            cout<< "[1]" << cinema[i][4] << "\n";
            cout<< "[2]" << cinema[i][5] << "\n";
            cout<< "[3]" << "CANCEL\n\n";
          
            while (true)
            {
                cout<< "Select time [1|2]: ";
                cin >> timeInput;
              
                if(timeInput == "1")
                {
                    timeInput = cinema[i][4];
                    successPicking = true;
                    break;
                }
                else if (timeInput == "2")
                {
                    timeInput = cinema[i][5];
                    successPicking = true;
                    break;
                }
                else if (timeInput == "3")
                {
                    system("cls");
                    break;
                }
                else
                {
                    cout<< "Invalid input, please try again...";
                }
            }
            if(successPicking)
            {
                cout<< "How many seats or tickets: ";
                cin >> seatInput;
                total = stoi(cinema[i][3]) * seatInput;
              
                cout<< "======================================\n";
                cout<< "Movie\n";
                cout<< cinema[i][2] << "\n";
                cout<< "Time: " << timeInput << "\n";
                cout<< "Price: P " << cinema[i][3] << "\n";
                cout<< "Seats: " << seatInput << "\n";
                cout<< "Total: " << total;
            }
            else
            {
                break;
            }
        }
    }
    return 0;
}

I convert mo nalang sa kung anong tinuro sa inyo.
 
To be frank, baka pagtawanan ka ng professor mo. Ayusin mo, isipin mo mabuti yung logic tapos sabi pa using for loop and arrays.


sa totoo lang paps , mas nakuha nyo ung pinapagawa samin ng prof ko , so un nga paps , mali ung sakin pero naayos ko na paps. kaso focus ni mam is ung sa for loop kaso gamit ko if statement esle if. salamat sir ng .amarami
 
To be frank, baka pagtawanan ka ng professor mo. Ayusin mo, isipin mo mabuti yung logic tapos sabi pa using for loop and arrays.
Sir pano i convert sa Java yan nag try po kasi ako i convert sa java walang error kaso hindi nman lumalabas yung pag nag select ka ng cinema saka movie walang nalabas. Gusto ko kasi matuto kaya pinag aaralan ko po tong code nyo.
 
Sir pano i convert sa Java yan nag try po kasi ako i convert sa java walang error kaso hindi nman lumalabas yung pag nag select ka ng cinema saka môviê walang nalabas. Gusto ko kasi matuto kaya pinag aaralan ko po tong code nyo.
Patingin ng code. Mas dadali ang usapan natin. :)
 
Status
Not open for further replies.

Similar threads

Back
Top