Teka saglit lang.Dikopo kasibgets yung function e paps. Hehe makapasa lang sa finals. Pwedi po pa function? Medyo nahuli napo kasi ako sa mga discussions e. Pero soon mag babasa nako nang mga book
Teka saglit lang.Dikopo kasibgets yung function e paps. Hehe makapasa lang sa finals. Pwedi po pa function? Medyo nahuli napo kasi ako sa mga discussions e. Pero soon mag babasa nako nang mga book
#include <iostream>
using namespace std;
string GiveMonth(int month)
{
switch (month)
{
case 1: return "January";
case 2: return "February";
case 3: return "March";
case 4: return "April";
case 5: return "May";
case 6: return "June";
case 7: return "July";
case 8: return "August";
case 9: return "September";
case 10: return "October";
case 11: return "November";
case 12: return "December";
default: return "";
}
}
int GiveNumberOfDays(int year, int month)
{
switch (month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
return 31;
case 4:
case 6:
case 9:
case 11:
return 30;
case 2:
{
//If leap year
if(year % 4 == 0)
{
return 29;
}
else
{
return 28;
}
}
}
}
int main()
{
int year = 2018;
int days = 0;
for(int i = 1; i < 13; i++)
{
cout<< GiveMonth(i) << endl;
days = GiveNumberOfDays(year, i);
for(int j = 1; j < days + 1; j++)
{
cout<< j << "\t";
if(j % 7 == 0)
{
cout << endl;
}
}
cout<< endl << endl;
}
}
Maraming salamat paps.Code:#include <iostream> using namespace std; string GiveMonth(int month) { switch (month) { case 1: return "January"; case 2: return "February"; case 3: return "March"; case 4: return "April"; case 5: return "May"; case 6: return "June"; case 7: return "July"; case 8: return "August"; case 9: return "September"; case 10: return "October"; case 11: return "November"; case 12: return "December"; default: return ""; } } int GiveNumberOfDays(int year, int month) { switch (month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: return 31; break; case 4: case 6: case 9: case 11: return 30; break; case 2: { //If leap year if(year % 4 == 0) { return 29; } else { return 28; } } } } int main() { int year = 2018; int days = 0; for(int i = 1; i < 13; i++) { cout<< GiveMonth(i) << endl; days = GiveNumberOfDays(year, i); for(int j = 1; j < days + 1; j++) { cout<< j << "\t"; if(j % 7 == 0) { cout << endl; } } cout<< endl << endl; } }
Pag-aralan mo yung ginawa ko tapos subukan mong gawin with your own muna para dyan sa bago tapos pakita mo sa akin nagawa mo, saka kita tutulungan. Ayaw ko spoonfeed di ba?Maraming salamat paps.
Pwede poba patulong ulet? Fufunction din po.
If pwede lang pho ulet hwhe.

#include <iostream>
#include <conio.h>
#include <iomanip>
#include <dos.h>
#include <string>
int p,response,t,choice;
string MOVIE[4]={"empty","TRANSFORMER [PG13]","DISTRICT 9[1☍+]","BAKIT MO AKO KINALABIT [1☍+]"};
int HALL[4]={0,1,2,3};
char ok;
double totalPrice;
double totalSale = 0.0;
double totalSale1 = 0.0;
double totalSale2 = 0.0;
int person ;
string PERSON[3]={"empty","ãdül†","Child"};
const double adultPrice=160.00;
const double childPrice=140.00;
void ******();
void foroosh();
char alpha[11] = {' ','A','B','C','D','E','F','G','H','I','J'};
int a,b;
int cinema[10][6];
int r,c;
struct ticketDetail
{
int x;
int movie,hall,seat;
};
ticketDetail cost;
void checkMenu;
{
cout<<"******************************"<<endl;
cout<<"CHOSEL CINEMA HOUSE"<<endl;
cout<<"[1] NOW SHOWING"<<endl;
cout<<"[2] BUY TICKET"<<endl;
cout<<"[3] EXIT"<<endl;
cout<<endl<<endl;
cout<<"Proceed with your choice: ";
cin>>cust.x;
};
void checkMovie()
{
textcolor(LIGHTGREEN);
cout<<"------------------------------"<<endl;
cout<<"NOW SHOWING IN CINEMA " "";
cout<<endl;
cout<<"------------------------------"<<endl;
cout<<"[1] TRANSFORMER [PG13]"<<endl;
cout<<"[2] DISTRICT [1☍+]"<<endl;
cout<<"[3] BAKIT MO AKO KINALABIT [1☍+]"<<endl;
cout<<"------------------------------"<<endl;
};
void printMovie(ticketDetail)
{
system("cls");
textcolor(LIGHTBLUE);
cout<<"******************************";
cout<<endl;
cout<<"[1] TRANSFORMER [PG13]"<<endl;
cout<<"[2] DISTRICT [1☍+]"<<endl;
cout<<"[3] BAKIT MO AKO KINALABIT [1☍+]"<<endl;
cout<<"******************************"<<endl;
cout<<endl;
};
void printHall(ticketDetail)
{
textcolor(LIGHTRED);
cout<<"------------------------------";
cout<<endl;
cout<<"MOVIE HALL";
count<<endl;
cout<<"------------------------------";
cout<<endl;
cout<<"[1] TRANSFORMER [PG13]"<<endl;
cout<<"[2] DISTRICT [1☍+]"<<endl;
cout<<"[3] BAKIT MO AKO KINALABIT [1☍+]"<<endl;
cout<<"------------------------------";
cout<<endl;
};
void exit()
{
exit(0);
};
void price()
{
if(cust.movie==1)
{
//******//;
cout<<"Price: "<<endl;
cout<<endl;
cout<<"[1] ãdül†"<<endl;
cout<<"[2] Child"<<endl;
cin>>choice;
if (choice==1)
p*adultPrice;
if (choice==2)
p*childPrice;
system("cls");
cout<<"Enter Number of Person: ";
cin>>person;
totalPrice=(p*person);
}
if (cust.movie==2)
{
cout<<"Price :"<<endl;
cout<<endl;
cout<<"[1] ãdül†"<<endl;
cout<<"[2] Child"<<endl;
cin>>choice;
if (choice==1)
p*adultPrice;
if (choice==2)
p*childPrice;
system("cls");
cout<<"Enter number of person: ";
cin>>person;
totalPrice=(p*person);
}
if(cust.movie==3)
{
cout<<"Price : "<<endl;
cout<<endl;
cout<<"[1] ãdül†"<<endl;
cout<<"[2] Child"<<endl;
cin>>choice;
if (choice==1)
p*adultPrice;
if (choice==2)
p*childPrice;
system("cls");
cout<<"Enter number of person: ";
cin>>person;
totalPrice=(p*person);
}
******();
};
void printTicket()
{
cout<<endl;
textcolor(WHITE);
cout<<"CHOSEL CINEMA HOUSE";
cout<<endl;
cout<<"------------------------------";
cout<<endl;
cout<<"MOVIE TITLE :";
cout<<MOVIE[cust.movie]<<endl;
cout<<"Hall :";
cout<<p<<endl;
cout<<"------------------------------";
cout<<endl;
};
void printReport()
{
cout<<endl;
cout<<endl;
textcolor(YELLOW);
cout<<"TOTAL SALE OF THE MOVIE: ";
cout<<endl;
cout<<"______________________________";
cout<<endl;
cout<<endl;endl;
if (cust.movie==1)
{
totalSale = totalSale + totalPrice;
}
if (cust.movie==2)
{
totalSale1 = totalSale1 + totalPrice;
}
if (cust.movie==3)
{
totalSale2 = totalSale2 + totalPrice;
}
cout<<"Transformer :";
cout<<totalSale<<endl;
cout<<"District 9 :";
cout<< totalSale1<<endl;
cout<<"Bakit Mo Ako Kinalabit :";
cout<<totalSale2<<endl;
cout<<endl;
};
void checkReport()
{
textcolor(PINK);
cout<<"REPORT OF TOTAL SALE PER MOVIE A DAY: ";
cout<<endl;
cout<<"------------------------------";
cout<<endl;
if (totalSale > totalSale1 && totalSale > totalSale2)
{
cout<<"Highest = "<< MOVIE[1]<<" :"<<totalSale<<endl;
}
if (totalSale1 > totalSale && totalSale1 > totalSale2)
{
cout<<"Highest = "<< MOVIE[2]<<" :"<<totalSale1<<endl;
}
if (totalSale2 > totalSale && totalSale2 > totalSale1)
{
cout<<"Highest = "<< MOVIE[3]<<" :"<<totalSale2<<endl;
}
if (totalSale <totalSale1 && totalSale < totalSale2)
{
cout<<"Lowest = "<< MOVIE[1]<<" :"<<totalSale<<endl;
}
if (totalSale1 <totalSale && totalSale1 < totalSale2)
{
cout<<"Lowest = "<< MOVIE[2]<<" :"<<totalSale1<<endl;
}
if (totalSale2 <totalSale && totalSale2 < totalSale1)
{
cout<<"Lowest = "<< MOVIE[3]<<" :"<<totalSale2<<endl;
}
cout<<"*********************************";
cout<<endl;
cout<<endl;
};
void ******()
{
system("cls");
cout<<"NO :\t1\t2\t3\t4\t5\t6 "<< endl;
for( a=0;a<=10;a++)
{
cout << alpha[a]<<" "<<endl;
for (b=0;b<=6;b++)
{
cout<< " ";
if (cinema[a][b]==0)
{
cout<<"*" << " ";
}
else
{
if (r==a && c==b)
{
cout<<"";
}
cout<<"X"<<" ";
}
}
cout<<endl;
}
void foroosh()
{
int r,c;
cout<<"Please Enter row number 0-15: ";
cin>>r;
cout>>"Please Enter col number 0-19 :";
cin>>c;
cout<<endl;
cinema[r][c]=1;
textcolor(LIGHTRED);
cout<<"Seat:";
cout<<alpa[r]<<c;
cout<<" is SOLO";
cout<<endl;
}
int main()
{
while(cust.x!=3)//ask user to enter choice of menu
{
system("cls");
checkMenu();
cout<<endl;
if(cust.x==1)
{
system("cls");
checkMovie();
cout<<endl<<endl;
cout<<"continue?";
cout<<endl;
cout<<"[1] yes"<<endl;
cout<<"[2] no"<<endl;
cin>>response;
cout<<endl;
if (response==1)
{
system("cls");
checkMenu();
}
else
exit();
cout<<"EXIT"<<endl;
}
if (cust.x==2)
{
system("cls");
cout<<endl;
printMovie(cust);
cout<<"Enter your choice:";
cin>>cust.movie;
printHall(cust);
cout<<"Enter your choice:";
cin>>cust.hall;
cout<<endl;
//******();
//cout<<endl;
price();
//******();
system("cls");
while(person!=0)
{
foroosh();
cout<<endl;
cout<<"please wait:";
for(a=0;a<2;a++)
{
cout<<(".");
sleep(1);
}
cout<<endl;
printTicket();
}
//system("cls");
printReport();
cout<<endl;
checkReport();
cout<<endl;
cout<<"Back to Menu? (Y)"<<endl;
cin>>ok;
if (ok == 'Y' || 'y')
{
sysmte("cls");
checkMenu();
}
}
if (cust.x==3)
{
exit();
cout<<endl;
}
}
getch();
return 0;
}
sa codes na to paps, ano gamit ng cust.x and so on lahat ng may cust, nakita ko lagn sa youtube.
Hindi yun cust. cost yun. Inaaccess niya yung parameters ng ticketdetails which dineclare mo as "cost".Code:#include <iostream> #include <conio.h> #include <iomanip> #include <dos.h> #include <string> int p,response,t,choice; string môviê[4]={"empty","TRANSFORMER [PG13]","DISTRICT 9[1☍+]","BAKIT MO AKO KINALABIT [1☍+]"}; int HALL[4]={0,1,2,3}; char ok; double totalPrice; double totalSale = 0.0; double totalSale1 = 0.0; double totalSale2 = 0.0; int person ; string PERSON[3]={"empty","*****","Child"}; const double adultPrice=160.00; const double childPrice=140.00; void ******(); void foroosh(); char alpha[11] = {' ','A','B','C','D','E','F','G','H','I','J'}; int a,b; int cinema[10][6]; int r,c; struct ticketDetail { int x; int môviê,hall,seat; }; ticketDetail cost; void checkMenu; { cout<<"******************************"<<endl; cout<<"CHOSEL CINEMA HOUSE"<<endl; cout<<"[1] NOW SHOWING"<<endl; cout<<"[2] BUY TICKET"<<endl; cout<<"[3] EXIT"<<endl; cout<<endl<<endl; cout<<"Proceed with your choice: "; cin>>cust.x; }; void checkmôviê() { textcolor(LIGHTGREEN); cout<<"------------------------------"<<endl; cout<<"NOW SHOWING IN CINEMA " ""; cout<<endl; cout<<"------------------------------"<<endl; cout<<"[1] TRANSFORMER [PG13]"<<endl; cout<<"[2] DISTRICT [1☍+]"<<endl; cout<<"[3] BAKIT MO AKO KINALABIT [1☍+]"<<endl; cout<<"------------------------------"<<endl; }; void printmôviê(ticketDetail) { system("cls"); textcolor(LIGHTBLUE); cout<<"******************************"; cout<<endl; cout<<"[1] TRANSFORMER [PG13]"<<endl; cout<<"[2] DISTRICT [1☍+]"<<endl; cout<<"[3] BAKIT MO AKO KINALABIT [1☍+]"<<endl; cout<<"******************************"<<endl; cout<<endl; }; void printHall(ticketDetail) { textcolor(LIGHTRED); cout<<"------------------------------"; cout<<endl; cout<<"môviê HALL"; count<<endl; cout<<"------------------------------"; cout<<endl; cout<<"[1] TRANSFORMER [PG13]"<<endl; cout<<"[2] DISTRICT [1☍+]"<<endl; cout<<"[3] BAKIT MO AKO KINALABIT [1☍+]"<<endl; cout<<"------------------------------"; cout<<endl; }; void exit() { exit(0); }; void price() { if(cust.môviê==1) { //******//; cout<<"Price: "<<endl; cout<<endl; cout<<"[1] *****"<<endl; cout<<"[2] Child"<<endl; cin>>choice; if (choice==1) p*adultPrice; if (choice==2) p*childPrice; system("cls"); cout<<"Enter Number of Person: "; cin>>person; totalPrice=(p*person); } if (cust.môviê==2) { cout<<"Price :"<<endl; cout<<endl; cout<<"[1] *****"<<endl; cout<<"[2] Child"<<endl; cin>>choice; if (choice==1) p*adultPrice; if (choice==2) p*childPrice; system("cls"); cout<<"Enter number of person: "; cin>>person; totalPrice=(p*person); } if(cust.môviê==3) { cout<<"Price : "<<endl; cout<<endl; cout<<"[1] *****"<<endl; cout<<"[2] Child"<<endl; cin>>choice; if (choice==1) p*adultPrice; if (choice==2) p*childPrice; system("cls"); cout<<"Enter number of person: "; cin>>person; totalPrice=(p*person); } ******(); }; void printTicket() { cout<<endl; textcolor(WHITE); cout<<"CHOSEL CINEMA HOUSE"; cout<<endl; cout<<"------------------------------"; cout<<endl; cout<<"môviê TITLE :"; cout<<môviê[cust.môviê]<<endl; cout<<"Hall :"; cout<<p<<endl; cout<<"------------------------------"; cout<<endl; }; void printReport() { cout<<endl; cout<<endl; textcolor(YELLOW); cout<<"TOTAL SALE OF THE môviê: "; cout<<endl; cout<<"______________________________"; cout<<endl; cout<<endl;endl; if (cust.môviê==1) { totalSale = totalSale + totalPrice; } if (cust.môviê==2) { totalSale1 = totalSale1 + totalPrice; } if (cust.môviê==3) { totalSale2 = totalSale2 + totalPrice; } cout<<"Transformer :"; cout<<totalSale<<endl; cout<<"District 9 :"; cout<< totalSale1<<endl; cout<<"Bakit Mo Ako Kinalabit :"; cout<<totalSale2<<endl; cout<<endl; }; void checkReport() { textcolor(PINK); cout<<"REPORT OF TOTAL SALE PER môviê A DAY: "; cout<<endl; cout<<"------------------------------"; cout<<endl; if (totalSale > totalSale1 && totalSale > totalSale2) { cout<<"Highest = "<< môviê[1]<<" :"<<totalSale<<endl; } if (totalSale1 > totalSale && totalSale1 > totalSale2) { cout<<"Highest = "<< môviê[2]<<" :"<<totalSale1<<endl; } if (totalSale2 > totalSale && totalSale2 > totalSale1) { cout<<"Highest = "<< môviê[3]<<" :"<<totalSale2<<endl; } if (totalSale <totalSale1 && totalSale < totalSale2) { cout<<"Lowest = "<< môviê[1]<<" :"<<totalSale<<endl; } if (totalSale1 <totalSale && totalSale1 < totalSale2) { cout<<"Lowest = "<< môviê[2]<<" :"<<totalSale1<<endl; } if (totalSale2 <totalSale && totalSale2 < totalSale1) { cout<<"Lowest = "<< môviê[3]<<" :"<<totalSale2<<endl; } cout<<"*********************************"; cout<<endl; cout<<endl; }; void ******() { system("cls"); cout<<"NO :\t1\t2\t3\t4\t5\t6 "<< endl; for( a=0;a<=10;a++) { cout << alpha[a]<<" "<<endl; for (b=0;b<=6;b++) { cout<< " "; if (cinema[a][b]==0) { cout<<"*" << " "; } else { if (r==a && c==b) { cout<<""; } cout<<"X"<<" "; } } cout<<endl; } void foroosh() { int r,c; cout<<"Please Enter row number 0-15: "; cin>>r; cout>>"Please Enter col number 0-19 :"; cin>>c; cout<<endl; cinema[r][c]=1; textcolor(LIGHTRED); cout<<"Seat:"; cout<<alpa[r]<<c; cout<<" is SOLO"; cout<<endl; } int main() { while(cust.x!=3)//ask user to enter choice of menu { system("cls"); checkMenu(); cout<<endl; if(cust.x==1) { system("cls"); checkmôviê(); cout<<endl<<endl; cout<<"continue?"; cout<<endl; cout<<"[1] yes"<<endl; cout<<"[2] no"<<endl; cin>>response; cout<<endl; if (response==1) { system("cls"); checkMenu(); } else exit(); cout<<"EXIT"<<endl; } if (cust.x==2) { system("cls"); cout<<endl; printmôviê(cust); cout<<"Enter your choice:"; cin>>cust.môviê; printHall(cust); cout<<"Enter your choice:"; cin>>cust.hall; cout<<endl; //******(); //cout<<endl; price(); //******(); system("cls"); while(person!=0) { foroosh(); cout<<endl; cout<<"please wait:"; for(a=0;a<2;a++) { cout<<("."); sleep(1); } cout<<endl; printTicket(); } //system("cls"); printReport(); cout<<endl; checkReport(); cout<<endl; cout<<"Back to Menu? (Y)"<<endl; cin>>ok; if (ok == 'Y' || 'y') { sysmte("cls"); checkMenu(); } } if (cust.x==3) { exit(); cout<<endl; } } getch(); return 0; }
ticketDetail cost;Hindi yun cust. cost yun. Inaaccess niya yung parameters ng ticketdetails which dineclare mo as "cost".
struct ticketDetail
{
int x;
int môviê,hall,seat;
};
ticketDetail cost;
cost.
Tapos
Code:struct ticketDetail { int x; int môviê,hall,seat; };
so yung cost.x, meaning gagamitin niya yung x ng cost which a ticketDetail.
Kung cin >> cost.x. Meaning maglalagay ako ng value sa x ng cost.
so on and so forth like sa cost.hall, cost.seat etc.
Para mag loop lang yung program. sa loob nung while loop.question po ulit, yung " while(true) " ano po need na pang declare at ano yung gamit niya
C ang printf at scanfSir samin po kasi ginamit namin
printf();
scanf();
Ano po yung
Cin at cout
Saka ano po ibigsabihin nang code na using name space std;
Thanks po
Ah yun pala yun salamat poC ang printf at scanf
C++ ang cout at cin