Hello guys,

i'm trying to write a menu for a C program that should implement a bank system but i'm having problems with my code...

I have tried to follow the example that my tutor gave on her lecture presentation, but to be honest i don't think i'm on the right path...

Each line of the menu is a function that i have to implement and, after each function performs the required action, it should return to the menu and wait for a new action from the user.

Here is my code and i also attach a file with the text of the program and a picture of how it should look like.

Any suggestion would be much appreciated,at least to get started.

Thanks,
Saphira

#include <stdio.h>
#include <ctype.h>
#include <string.h>

void DisplayMainMenu();

int main ( void )
{
	int menu_item;
	do
	{
		DisplayMainMenu();
		menu_item=0;
			while (menu_item<1 || menu_item>4)
			{
				printf("\nChoose an option between 1 and 10:");
				scanf_s("%d", &menu_item);
			}/* end of while */

			switch (menu_item)
			{
				case 1:
					LoadDatabase( );	
					break;

				case 2:
					AddNewCustomerAccount( );	
					break;

				case 3:
					CloseCustomerAccount( );	
					break;

				case 4:
					DisplayAllCustomers ( );
					break;

				case 5:
					ChangeCustomerAddress ( );
					break;

				case 6:
					SortCustomerByCreditLimit ( );
					break;

				case 7:
					DecreaseCreditLimit ( );
					break;

				case 8:
					SaveCustomers ( );
					break;

				case 9:
					ExtraFunctions ( );
					break;

				default:
					break;

			}/* end of switch */
	}/* end of do while */
		
		while (menu_item != 10);
		printf("\n\nThank You abd God Bye!\n\n");
}/* end of main */

void DisplayMainMenu()
{
	printf( "_____________________________________________\n\n" );
	printf( "\t\tNew Irish Bank\n\n" );
	printf( "_____________________________________________\n" );
	printf("\nPlease choose one of the following options:\n\n" );
	printf("1. Load Database\n");
	printf("2. Add New Customer Account\n");
	printf("3. Close Customer Account\n");
	printf("4. Display All Customers\n");
	printf("5. Change Customer Address\n");
	printf("6. Sort Customer by Credit Limit\n");
	printf("7. Decrease Credit Limit\n");
	printf("8. Save Customers\n");
	printf("9. Extra Functions\n\n");
	printf("10.Exit\n");
	printf( "_____________________________________________\n\n" );
	printf( "\t\tEnter Choice:\n\n" );
	printf( "_____________________________________________\n" );
}

And what specifically is the problem?

The only thing I see wrong is that you need to prototype each of those functions that are being called in that switch statement. Otherwise looks like it should compile and work ok.

The problem is that the OP has not yet written any code. This looks like code handed out with the assignment.

BTW, shouldn't the tab size for displaying code on this site be 4, not 8?

On the plus side, they did manage to use code tags on the first attempt, despite running around screaming "FIRE FIRE"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.