|
 |
- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -
|
|
 |
กระทู้ #1862 [C] (จาก IP: 203.185.143.229)
ขอตัวอย่าง Code สร้างเมนูหน่อยครับ
ขอรบกวนหน่อยนะครับ เพิ่งเริ่มอะครับ
|
จากคุณ
:
Head34 / goahead34@gmail.com [2008-03-04 10:35:44]
|
|
ความคิดเห็น #26596 (จาก IP: 203.156.142.66)
#include <iostream> #include <conio.h>
using std::cout; using std::cin; using std::endl;
struct cardholder { char name[10]; //name of student int SSN; // social security number char cardtype[10]; float balance; };
typedef struct cardholder CARD; void menu (CARD hold[], int arraycounter); void addholder(CARD hold[], int arraycounter); void printholder(CARD hold[]); //void findholders(CARD hold[]);
int main() { int arraycounter = 0; CARD holder[10];
menu (holder, arraycounter);
return 0; }
void addholder(CARD hold[], int arraycounter) // add holder function {
cout << "Enter student name\n"; cin >> hold[arraycounter].name;
cout << "Enter social security number\n"; cin >> hold[arraycounter].SSN;
cout << "Enter card type\n"; cin >> hold[arraycounter].cardtype;
cout << "Enter balance\n"; cin >> hold[arraycounter].balance;
arraycounter++;
}
void printholder(CARD hold[]) { int social; social = 0;
cout << "Please enter the social security number" << endl << endl; cin >> social;
for (int i = 0; i < 10; i++ ) { if ( social == hold[i].SSN ) { cout << "Student SSN: " << hold[i].SSN << endl; cout << "Student Name: " << hold[i].name << endl; cout << "Card Type: " << hold[i].cardtype << endl; cout << "Balance: " << hold[i].balance << endl; cout << endl; } } } void menu (CARD hold[], int arraycounter) { int menuvalue; CARD holder[10];
cout << "Select a option\n"; cout << " 1 Enter a new holder\n"; cout << " 2 Print holders information\n"; cout << " 3 Find holder\n"; cout << " 4 to quit\n"; cin >> menuvalue;
if( menuvalue == 1 ){ addholder (holder, arraycounter); menu (holder, arraycounter); } else if ( menuvalue == 2 ){ printholder(holder); menu (holder, arraycounter); } //else if (menuvalue == 3){ // find_holders(holder); //}
else if (menuvalue == 4){ int quit; cout << "Are you sure you wish to quit?" << endl << endl; cout << "1: Yes, quit." << endl; cout << "2: No, continue working." << endl; cin >> quit; if (quit == 1){ void exit (); } else if (quit == 2){ menu (holder, arraycounter); } } }
|
จากคุณ
:
sup98 [2008-03-06 09:38:11]
|
 |
ความคิดเห็น #28087 (จาก IP: 182.53.199.62)
ลองดูครับ
#include<stdio.h> #include<stdlib.h> int main (int argc, char*argv[]) { int n,m=0,u=0; char a; for(;;) { printf("\n\t *** Menu pay water ***\n"); printf("\n\t1.unit at 0-10 you pay 50 bath\n\t2.unit at 11-25 you pay:unit 15 bath\n\t3.unit at 26-40 you pay:unit 10 bath\n\t4.unit at 41++ you pay:unit 7 bath\n\t5.Exit Program.\n\n"); printf("Please select menu=> "); scanf("%d",&n); if(n==1) { system("cls"); printf("\n\n >> you must pay of water is money 50 bath <<\n"); system("PAUSE"); system("cls"); } else if(n==2) { printf("Enter unit of water 11-25 unit => "); scanf("%d",&u); m=50+((u-10)*15); system("cls"); printf("\n\n >> you must pay of water is money %d bath <<\n",m); system("PAUSE"); system("cls"); } else if(n==3) { printf("Enter unit of water 26-40 unit => "); scanf("%d",&u); m=275+((u-25)*10); system("cls"); printf("\n\n >> you must pay of water is money %d bath <<\n",m); system("PAUSE"); system("PAUSE"); system("cls"); } else if(n==4) { printf("Enter unit of water 41++ unit => "); scanf("%d",&u); m=425+((u-40)*7); system("cls"); printf("\n\n >> you must pay of water is money %d bath <<\n",m); system("PAUSE"); system("cls"); } else if(n==5) { exit(0); } else { printf("you error selection are you new select menu=> "); scanf("%s",&a); if(a=='n') { exit(0); } else { system("cls"); } } } system("PAUSE"); return 0; } |
จากคุณ
:
n / nik_pattanakul@hotmail.com [2010-12-10 10:05:39]
|
 |
|
- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -
|
|
|
|
|