Starting from:

$25

CSE102 - Computer Programming  - Homework 9  - Solved

In this homework, you will implement a banking system. This homework will be implemented by using Structs, Unions, Recursive functions and File operations in C. You need 2 unions and 1 struct type. These are;

union Person 

{     char name[50];     char address[50];     int phone; 

}; 

union Loan 

{     float amount;     float interestRate;     int period; 

}; 

struct BankAccount 



    union Person Customer;     union Loan Loans[3]; 

}; 
 

The first union structure is Person. This union has to keep personal information. This value may change, in the image, it is for example purposes only. You can add extra information. The second union is credit. Here, it should keep the amount of the loan, the interest rate and the number of periods. The struct is BankAccount. Inside the struct, you have to keep Person and Loan of type union. You will open bank accounts within the system and assign loans to customers by calculating loans. Each customer can only have 3 loans. Banking system keeps maximum 50 customer in same time. Each fields are will be get from user input with using command line.

 

Function prototypes are : listCustomers() addCustomer () newLoan () 

calculateLoan(float amount, int period, float interestRate); 

getReport(); 

You have to use a recursive function when calculating the loan. You are not allowed to use the pow() function. The formula for calculating the loan is below.

𝑳𝒐𝒂𝒏 𝑭𝒐𝒓𝒎𝒖𝒍𝒂 = 𝑨𝒎𝒐𝒖𝒏𝒕 ∗ ( 𝟏 + 𝒊𝒏𝒕𝒆𝒓𝒆𝒔𝒕𝑹𝒂𝒕𝒆)𝒑𝒆𝒓𝒊𝒐𝒅 

In the report section, you have to print out 2 reports. These are the Customer list and Loan detail. You must keep all customers in the customers.txt file. When requesting this report, you must read customers.txt file and print the customers to the screen. When printing a loan detail of a customer, you need to print the total value of that loan and each period one by one as in the example. Not all states are shown in the expected outputs, but you have to check all states and incorrect entries for each step. You can specify the function types according to your needs. Unless the program exit option is selected, it has to return to the menu after each operation. Remember, the list in option 1 has to print the customers in the struct to the screen. The report menu in the 4th option has to print the customers and loans it reads from the file on the screen.

 

Expected Outputs

More products