-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathOfficeOfAccounts.cpp
116 lines (106 loc) · 3.46 KB
/
OfficeOfAccounts.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// OfficeOfAccounts Header File
#include <iostream>
#include <cstring>
#include <bits/stdc++.h>
#ifdef WIN32
#include <ncurses/ncurses.h>
#else
#include <ncurses.h>
#endif
#include "OfficeOfAcademics.h"
#include "OfficeOfAccounts.h"
#define ExpensesPath "Expenses.txt"
#define SUCCESSFUL 1
#define YES 1
#define NO 0
int count3=0;
void LOGINSTART();
void OfficeOfAccounts:: login()
{
char EmployeeID[40], pass[40];
std::cout << "Enter EmployeeID: " ;
std::cin >> EmployeeID;
initscr(); // enable ncurses
printw("Enter Password: ");
noecho(); // disable character echoing
getnstr(pass,sizeof(pass));
echo(); // enable character echoing again
// getch(); // Wait for a keypress
endwin(); // disable ncurses
// std::cout << std::endl;
int loginverify = OfficeOfAcademics::VerifyCredentials(EmployeeID, pass);
if(loginverify==SUCCESSFUL)
{
std::cout << ("\n** Login Successful! **\n\n");
DisplayOptions();
}
else
{
std::cout << ("Enter credentials again\n");
count3++;
if(count3==3)
{
printf("You have entered the wrong credentials three times\n\n");
::LOGINSTART();
}
login();
}
}
void OfficeOfAccounts:: ViewMedicalExpenses()
{
std::cout << "Cumulative Medical Expenses: Rs. ";
FILE *fp = fopen(ExpensesPath,"r");
double amt;
fscanf(fp,"%lf", &amt);
fclose(fp);
printf("%lf\n",amt);
}
void OfficeOfAccounts:: UpdateExpenses(double amt)
{
FILE *fp = fopen(ExpensesPath,"r");
double StoredAmount;
fscanf(fp,"%lf", &StoredAmount);
fclose(fp);
amt += StoredAmount;
fp = fopen(ExpensesPath,"w");
fprintf(fp,"%.2lf",amt);
fclose(fp);
}
void OfficeOfAccounts:: DisplayOptions()
{
int incorrectChoice = NO;
int repeat = YES;
do
{
std::cout << " 1:View Medical Expenses\n"; //can be made into two if we want(for whole expenses and for particular patient)
std::cout << "Enter your choice (The corresponding number): ";
int choice;
std::cin >> choice;
switch(choice)
{
case 1: //getting Medical expenses record
{
ViewMedicalExpenses();
break;
}
default:
{
std::cout << "Please enter a valid option!\n";
incorrectChoice = YES;
}
}
if(incorrectChoice == YES)
repeat = YES;
else
{
std::cout << " Do you wish to perform more functions as an OfficeOfAccounts user? (Yes/No): ";
std::string resp1;
std::cin >> resp1;
std::transform(resp1.begin(), resp1.end(), resp1.begin(), ::tolower);
if(resp1.std::string::compare("yes")==0)
repeat = YES;
else
repeat = NO;
}
}while(repeat == YES);
}