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 GUI program that would facilitate text chatting/exchanging between two or multiple computers over...
Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If you do not have any network environment, you can run on a single machine by instantiating your program multiple times. E.g. you can have program1 and program 2 running on same machine exchanging texts between themselves.
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 Java program for a simple bank account. You shall define a Customer class: A...
Write a Java program for a simple bank account. You shall define a Customer class: A customer has a first name, last name, and social security number. The social security number is a String variable and must comply with this format: xxx-xx-xxxx where 'x' is a digit between 0-9. If a customer is supplied with an invalid SSN, a message must be printed stating SSN of the customer is invalid; however, the account still is created. You shall define a...
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...
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
How to write IO program in java?
How to write IO program in java?
This has to be in java and will be uploaded onto zybooks. Write a Java program...
This has to be in java and will be uploaded onto zybooks. Write a Java program that asks the user for a date entered as 4 integers: dayNumber monthNumber date year. Where: dayNumber An integer from 1-7, where 1 = Sunday, 2 = Monday, ..., 7 = Saturday monthNumber An integer from 1-12, where 1 = January, 2 = February, ..., 12 = December date An integer from 1-31 representing the date. year An integer representing the year. Your prompt...
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...
Write in Java * Create a new client class called Plants.java * Write code in the...
Write in Java * Create a new client class called Plants.java * Write code in the Plants class that solves problems 1,2,3 and 4 * Include the solutions of the different problems in different methods and call them from the main method * Use the BagInterface.java and ArrayBag.java, but do not add any code Problem 1: Create a bag plantsCart, which holds the following spring seedlings(represented by String) Rose, Daisy, Cabbage, Cucumber, Carrot, Cucumber, Daffodil, Daisy, Rose, Iris, Rose, Spinach....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT