Question

In: Computer Science

Online bank loan sanction facility is launched to facilitate the client. Write a java program to...

Online bank loan sanction facility is launched to facilitate the client. Write a java program to create class Loan with data members client name, address, age, salary, loan amount, loan type(housing, vehicle, personal) . Take the necessary inputs and write the object into the file. The bank manager will fetch the loan details from the file and verify the details for approval.

a. Write a java program for a client to submit the application in a file.

b. Write a java program for a bank manager to fetch the details from the file for approval.. Single line text.

Solutions

Expert Solution

(A). Client program code

import java.io.*;
import java.util.Scanner;

class Loan {
   private String name, age, address, salary, loanAmount, loanType;
//constructor for variable initialization
   Loan(String n, String age, String address, String salary, String la, String lt) {
       this.name = n;
       this.age = age;
       this.address = address;
       this.salary = salary;
       this.loanAmount = la;
       this.loanType = lt;

   }
//function to store the data in the file
   public void createUser() {
       try {
           File fobj = new File("S:\\banking.txt"); /* creating the object of File class(Enter location according to your choice)*/
           fobj.createNewFile(); // creating file
           FileWriter myWriter = new FileWriter("S:\\banking.txt", true); /* creating FileWriter object to write in the file*/
           BufferedWriter out = new BufferedWriter(myWriter);
           out.write(this.name + " " + this.age + " " + this.address + " " + this.salary + " " + this.loanAmount + " " + this.loanType + "\n");
           out.close();
       } catch (IOException e) {
           System.out.println(e);
       }

   }

}

class Banking {
   public static void main(String[] args) {
       Scanner obj = new Scanner(System.in);
       System.out.println("Enter name");
       String name = obj.nextLine();
       System.out.println("Enter age");
       String age = obj.nextLine();
       System.out.println("Enter Loan type and choices are Housing, Vehicle, Personal");
       String loan_type = obj.nextLine();
       System.out.println("Enter Salary");
       String sal = obj.nextLine();
       System.out.println("Enter Loan Amount");
       String loan_amount = obj.nextLine();
       System.out.println("Enter address ");
       String add = obj.nextLine();
       Loan user = new Loan(name, age, add, sal, loan_amount, loan_type);//create object of class Loan
       user.createUser();//call function to store data in file
       System.out.println("Record added successfully");
       obj.close();

   }
}

OUTPUT:

(B). Manager program

import java.io.File; // File class
import java.io.FileNotFoundException; // class to handle errors
import java.util.Scanner; // Scanner class to read text files
public class Manager {
public static void main(String[] args) {
System.out.println(" NAme Age Address Salary Loan Amount Loan Type ");
try {
File obj = new File("S:\\banking.txt"); //creating the file object
Scanner sc = new Scanner(obj); //creating the object of scanner class to read file content
int i=1;
while (sc.hasNextLine()) { //Run while loop until the file has lines
String data = sc.nextLine();
System.out.println(i+". " + data); //printing the line of file
i++;
}
sc.close();
} catch (FileNotFoundException e) { // to catch exception
System.out.println("An error occurred.");
e.printStackTrace(); //print the stack of exception
}
}
}

OUTPUT:


Related Solutions

Write a Java program to process the information for a bank customer.  Create a class to manage...
Write a Java program to process the information for a bank customer.  Create a class to manage an account, include the necessary data members and methods as necessary.  Develop a tester class to create an object and test all methods and print the info for 1 customer.  Your program must be able to read a record from keyboard, calculate the bonus and print the details to the monitor.  Bonus is 2% per year of deposit, if the amount is on deposit for 5 years...
Write a program in java processing. Write a program that does the following: · Assume the...
Write a program in java processing. Write a program that does the following: · Assume the canvas size of 500X500. · The program asks the user to enter a 3 digit number. · The program then checks the value of the first and last digit of the number. · If the first and last digits are even, it makes the background green and displays the three digit number at the mouse pointer. · If the two digits are odd, it...
How to write IO program in java?
How to write IO program in java?
Write a program that computes loan payments. The loan can be a car loan, astudent loan,...
Write a program that computes loan payments. The loan can be a car loan, astudent loan, or a home mortgage loan. The program let’s the user enter theinterest rate, number of years, and loan amount, and displays the monthly andtotal payments. in Java. COP 2510
write a Java program Write a program to assign a letter grade according to the following...
write a Java program Write a program to assign a letter grade according to the following scheme: A: total score >= 90 B: 80 <= total score < 90 C: 70 <= total score < 80 D: 60 <= total score < 70 F: total score < 60 Output - the student's total score (float, 2 decimals) and letter grade Testing - test your program with the following input data: test1 = 95; test2 = 80; final = 90; assignments...
Write the program in java Write a program that does basic encrypting of text. You will...
Write the program in java Write a program that does basic encrypting of text. You will ask the user the filename of a text file which contains a few sentences of text. You will read this text file one character at a time, and change each letter to another one and write out to an output file. The conversion should be done a -> b, b->c , … z->a, A->B, B->C, …. Z->A. This means just shift each letter by...
This program must be done in JAVA. Write a program to monitor the flow of an...
This program must be done in JAVA. Write a program to monitor the flow of an item into an out of a warehouse. The warehouse has numerous deliveries and shipments for this item (a widget) during the time period covered. A shipment out (an order) is billed at a profit of 50% over the cost of the widget. Unfortunately each incoming shipment may have a different cost associated with it. The accountants of the firm have instituted a last-in, first...
Program: Java Write a Java program using good programming principles that will aggregate the values from...
Program: Java Write a Java program using good programming principles that will aggregate the values from several input files to calculate relevant percentages and write the values to an output file. You have been tasked with reading in values from multiple files that contains different pieces of information by semester. The Department of Education (DOE) would like the aggregate values of performance and demographic information by academic year. A school year begins at the fall semester and concludes at the...
Program: Java Write a Java program using good programming principles that will aggregate the values from...
Program: Java Write a Java program using good programming principles that will aggregate the values from several input files to calculate relevant percentages and write the values to an output file. You have been tasked with reading in values from multiple files that contains different pieces of information by semester.    The Department of Education (DOE) would like the aggregate values of performance and demographic information by academic year. A school year begins at the fall semester and concludes at the...
DO THIS IN JAVA Write a complete Java program. the program has two threads. One thread...
DO THIS IN JAVA Write a complete Java program. the program has two threads. One thread prints all capital letters 'A' to'Z'. The other thread prints all odd numbers from 1 to 21.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT