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...
The client needs this program written in Java. Your team is tasked to create a program...
The client needs this program written in Java. Your team is tasked to create a program that converts Fahrenheit to Celsius. Fahrenheit temperature of 87.6 degrees. Convert it to Celsius, and display the temperature in both units. Your output should look similar to the following: Fahrenheit Temperature: 87.6 Celsius Temperature: 30.88
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 that creates a text file. Write to the file...
Write a java program: Write a program that creates a text file. Write to the file three lines each line having a person's name. In the same program Append to the file one line of  'Kean University'.  In the same program then Read the file and print the four lines without lines between.
Write program#2 upload .java file. 2A) Write a java program that uses the Random class to...
Write program#2 upload .java file. 2A) Write a java program that uses the Random class to generate a number in the range 21 to 64.  Print the generated number. 2B) Using the Random class and nextInt(6), rolls two die generating two random numbers each in the range 1 through 6. Total by adding the two values together. Print the value of each die, and the total value. 2C) Using the Math class and sqrt(num), calculate the square root of integer twenty-two...
Write program#1 upload .java file. #1 Write a java program that prompts the user for input...
Write program#1 upload .java file. #1 Write a java program that prompts the user for input using the Scanner class. First to enter their first name. Then prompts the user to enter their last name. Then prompts the user to enter their city. Then prompts the user to enter their state. Then prompts the user to enter their zip code. Concatenate first name and last name into full_name. Using String Class is optional. Use the String Class to replace zip...
Write program#1 upload .java file. #1 Write a java program that prompts the user for input...
Write program#1 upload .java file. #1 Write a java program that prompts the user for input using the Scanner class. First to enter their first name. Then prompts the user to enter their last name. Then prompts the user to enter their city. Then prompts the user to enter their state. Then prompts the user to enter their zip code.   Concatenate first name and last name into full_name. Using String Class is optional. Use the String Class to replace zip...
Write program#2 upload .java file. 2A) Write a java program that uses the Random class to...
Write program#2 upload .java file. 2A) Write a java program that uses the Random class to generate a number in the range 21 to 64.  Print the generated number. 2B) Using the Random class and nextInt(6), rolls two die generating two random numbers each in the range 1 through 6. Total by adding the two values together. Print the value of each die, and the total value. 2C) Using the Math class and sqrt(num), calculate the square root of integer twenty-two...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT