Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
void startup_message();
void login_process();
void menu_and_startup();
void add_transferees();
void view_transferees();
void remit_money();
void thank_you_message();
int main ()
{
startup_message();
login_process();
menu_and_startup();
return 0;
}
void startup_message()
{
printf("Welcome to the newly introduced smsTransfer© (remittances through SMS text messaging)!\n");
printf("a joint project of PioneerBank and Globe Telecom!\n");
printf("REMINDER: Both the transferers and the transferees must have active accounts with both companies to take part in this service.\n\n");
}
void login_process()
{
char username[10];
char correct_username[10];
char second_part_of_correct_username[5];
char firstname[10];
char lastname[20];
long long int cin;
long long int correct_password;
long long int password;
short int attempts=0;
printf("Enter your first name:\n");
scanf("%s",firstname);
strncpy(correct_username,firstname,2);
correct_username[2]='\0';
printf("Enter your last name:\n");
scanf("%s",lastname);
strncpy(second_part_of_correct_username,lastname,3);
second_part_of_correct_username[3]='\0';
strncat(correct_username,second_part_of_correct_username,5);
printf("Enter your Customer Identification Number(CIN):\n");
scanf("%llu",&cin);
correct_password=(cin%10)+1;
printf("Please note that usernames are case sensitive.\n");
printf("Enter username:\n");
scanf("%s",&username);
printf("Enter password:\n");
scanf("%llu",&password);
if ((password==correct_password) && strcmp(username,correct_username)==0)
{
printf("Login successful!\n");
}
while ((password!=correct_password) || strcmp(username,correct_username)!=0)
{
printf("\nThe login details are invalid.Please try again.\n");
printf("Enter username:\n");
scanf("%s",&username);
printf("Enter password:\n");
scanf("%llu",&password);
attempts++;
if (attempts>=5)
printf("Too many tries. Please re-enter the program and attempt to complete the login process again.\n");
if (attempts>=5)
exit(0);
if ((password==correct_password) && strcmp(username,correct_username)==0)
printf("Login successful!\n");
}
}
void menu_and_startup()
{
short int option;
do
{
printf("___________________________________________\n");
printf("1. Add transferees\n");
printf("2. View current transferee list\n");
printf("3. Remit money\n");
printf("4. Account information and settings\n");
printf("5. Exit the application\n");
printf("____________________________________________\n");
printf("Please choose from the above options: \n");
scanf("%d",&option);
switch(option)
{
case 1: add_transferees();
break;
case 2: view_transferees();
break;
case 3: remit_money();
break;
case 4: add_transferees();
break;
case 5: thank_you_message();
exit(0);
}
} while(option>0 && option<6);
}
void add_transferees()
{
FILE *file;
int i;
char firstName[32];
char lastName[32];
char email_address[40];
long long int account_number;
long int phone_number;
short int addchoice;
int found = 0;
file = fopen("transferee_list.txt", "a");
if (!file)
{
printf("File could not be opened\n\a\a");
getchar();
exit(-1);
}
printf("Enter number of transferees you wish to add:\n");
scanf("%d",&addchoice);
for (i = 0; i<addchoice; ++i)
{
printf("Transferee #%d\n", i+1);
printf("Enter first name:\n"); scanf("%s", &firstName);
printf("Enter last name:\n"); scanf("%s", &lastName);
printf("Enter PioneerBank account number:\n"); scanf("%llu", &account_number);
printf("Enter e-mail address:\n"); scanf("%s", &email_address);
printf("Enter Globe Telecom phone number:\n"); scanf("%lu",&phone_number);
printf("\n");
fprintf(file, "%s\t%s\t%llu\t%s\t%lu\n", firstName, lastName,account_number,email_address,phone_number);
}
printf("Transferee list successfully updated!\n");
fclose(file);
}
void view_transferees()
{
char firstName[32];
char lastName[32];
char email_address[40];
long long int account_number;
long int phone_number;
int found=0;
FILE *file;
file = fopen("transferee_list.txt", "r");
if (!file)
{
printf("File could not be opened\n\a\a");
exit(-1);
}
else
{
fscanf(file, "%s\t%s\t%llu\t%s\t%lu", &firstName,&lastName,&account_number,&email_address,&phone_number);
{
printf("Current transferees:\n First Name:%s\n Last Name:%s\n Account Number:%llu\n E-mail address:%s\n Phone Number:%lu\n", firstName, lastName, account_number, email_address, phone_number);
found = 1;
}
}
if (!found)
printf("Record could not be found");
fclose(file);
}
void remit_money()
{
char transferee_name[30];
float current_balance;
float transfer_amount;
printf("\nCurrent chequing amount balance:%.2f",current_balance);
printf("Please enter the transferee name:");
scanf("%s",&transferee_name);
printf("\nEnter the desired transfer amount:$");
scanf("%.2f",&transfer_amount);
if (transfer_amount<5000 && transfer_amount<current_balance && current_balance-transfer_amount>=10000)
current_balance-=transfer_amount;
while (transfer_amount>=5000)
{
printf("In accordance with the Mobile Banking Act of 2024, customers are prohibited from sending amounts in excess of $5,000 per transaction.");
printf("\nEnter the desired transfer amount:$");
scanf("%.2f",&transfer_amount);
if (transfer_amount<5000 && transfer_amount<current_balance && current_balance-transfer_amount>=10000)
current_balance-=transfer_amount;
}
}
void thank_you_message()
{
printf("Thanks for choosing and using smsTransfer©!\n");
}