Jump to content
Sign in to follow this  
Daftpunk

Nk Tanya Coding

Recommended Posts

assalamualaikum guys. saya ada satu perkara nk mintak tlg. saya tak tahu coding bagi soalan ni yg terdapat dlm assignment saya :

Q3 Write an interactive, menu-driven C program of fitness center information and reservation system

apakah coding untuk login program itu?

Share this post


Link to post
Share on other sites
biasanya coding dia start gini:

[code]#include <stdio.h>[/code]


  :blush:

Share this post


Link to post
Share on other sites
Just to share: Menu driven maksudnye boleh pilih task berdasarkan list menu yg kita buat.
[code]
Please select your menu (Enter 1-3 only):
1. Add user
2. Find user
3. Delete user

User select > _
[/code]

Sample coding (Borland Turbo C++ compiler - oldskool tapi very2 good).

[img]https://sites.google.com/site/myccodesnippet/_/rsrc/1296033684639/home/sample_menu_driven.PNG[/img]

[code]
// compiler: Turbo C++ v3.1 for Windows
// level: beginner

#include <stdio.h>
#include <conio.h>

// definition - untuk senangkan kejer
#define p printf
#define ESC 0x1B

// function prototypes
void Show_Menu(void);
void Process_Input (int selection);

// boleh call byk kali, so letak kat function
void Show_Menu(void) {
p("\nMENU:\n");
p("1. Add user\n");
p("2. Find user\n");
p("3. Remove user\n");
p("Enter selection (ESC to quit) > ");
}

// proses input yang user tekan - kat sini macam2 lagi boleh buat...
void Process_Input (int selection) {
p("\n");

switch (selection) {

case '1':
p("...Task 1: Add user. There is lots more to do here..open file...get user name, info, etc..save file..close it.\n");
break;

case '2':
p("...Task 2: Find user. Open file...find user...print info..close file.\n");
break;

case '3':
p("...Task 3: Remove user. Open file...find user...remove info..close file.\n");
break;

default:
p("Unknown -> %02X!\n", selection);
break;
}
}

// main loop - guna void, xyah return integer i.e return 0
void main() {
int user_press;

p("\n=== Menu driven sample program by Ramzi ===\n");

// infinite loop
while (1) {

// tiap kali loop - tunjuk menu
Show_Menu();

// dapatkan menu selection dari user - tekan keyboard, hanya 1-3 sahaja, boleh tambah sukati...
user_press = getch();

// untuk valid nombor shj yg perlu print, kalau nk print sumer, comment if statement
if (user_press > '0' && user_press < '4') {
p("%c", user_press);
}

// kalau user tekan ESCAPE, exit while loop
if (user_press == ESC)
break;

// user tak tekan ESCAPE, jadi proses input
else
Process_Input(user_press);
}

p("\nUser terminate application!\n");
}
[/code]

Byk lagi yg boleh di olah & ditambah...atas kreativiti masing2...

Share this post


Link to post
Share on other sites
[quote name='AmD SeMpoT (SeMpRoN)' timestamp='1286455555' post='1049648']
assalamualaikum guys. saya ada satu perkara nk mintak tlg. saya tak tahu coding bagi soalan ni yg terdapat dlm assignment saya :

Q3 Write an interactive, menu-driven C program of fitness center information and reservation system

apakah coding untuk login program itu?
[/quote]

ni nak 'pencerahan' atau nak mintak orang tolong buatkan kerjarumah?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...