What's new

Closed Help!!! Need Help!

Status
Not open for further replies.

AnoNhiemousAce

Enthusiast
Joined
Apr 23, 2015
Posts
2
Reaction
0
Points
62
Age
26
import java.io.*;
import java.util.*;
import java.text.*;

class qwer
{
public static void main (String [] args)throws Exception
{
String var1="\t Client NO: ",var2="\t Client Name: ",var3="\t Loan Amount: ",var4="\t Interest: ",var5="\t Total Loan Amount: ",var6="==================================================";
Scanner scn=new Scanner (System.in);
double TLoan=0.00,Interest=0,Loan=0;
File rFile=new File("Qwerty.txt");
DecimalFormat dcml=new DecimalFormat ("#,000.00");
BufferedWriter bWrite=new BufferedWriter(new FileWriter(rFile,true));
System.out.println("");
System.out.println("Select option to perform");
System.out.println("");
System.out.print("[A-Add Record |");
System.out.print("| V-View Record]: ");
String Select=scn.next();
System.out.println("");
if (Select.equals("A")|| Select.equals("a"))
{
System.out.println("Add Record: ");
System.out.println("");
System.out.print(var1);
int cNo=scn.nextInt();

System.out.print(var2);
String cName=scn.next();

System.out.print(var3);
Loan=scn.nextInt();
String format1=dcml.format (Loan);
if (Loan>=1000&&Loan<=5000)
{
Interest=Loan*.05;
}
if (Loan>5000&&Loan<=10000)
{
Interest=Loan*.10;
}
if (Loan>10000&&Loan<=15000)
{
Interest=Loan*.15;
}
if (Loan>15000&&Loan<=20000)
{
Interest=Loan*.20;
}
else if (Loan>20000)
{
System.out.print("Error Max Loan Amount is 20k!!");
System.out.print("Re-run Program!!");
System.out.print("Transaction not saved!!");
System.exit (0);
}
System.out.println(var4+Interest);
TLoan=Loan+Interest;
String format2=dcml.format (Interest);
System.out.println(var5+TLoan);
String format3=dcml.format (TLoan);
System.out.print(" Save? Y/N: ");
String Rec=scn.next();
System.out.println(var6);
if (Rec.equals("Y") || Rec.equals("y"))
{
bWrite.write(var1+cNo);
bWrite.newLine();

bWrite.write(var2+cName);
bWrite.newLine();

bWrite.write(var3+Loan);
bWrite.newLine();

bWrite.write(var4+Interest);
bWrite.newLine();

bWrite.write(var5+TLoan);
bWrite.newLine();

bWrite.write(var6);
bWrite.newLine();
bWrite.close();
}
else if (Rec.equals("N") || Rec.equals("n"))
{
System.exit (0);
}
else
{
System.out.print("Error Option!!");
System.out.print("Re-run Program!!");
System.out.print("Transaction not saved!!");
System.exit (0);
}
}
else if (Select.equals("V")|| Select.equals("v"))
{
FileReader read=new FileReader ("QWERTY.txt");
BufferedReader bffread=new BufferedReader (read);
String reader=" ";
while ((reader=bffread.readLine())!=null)

System.out.println(reader);
}
else
{
System.out.print("Error Option!!");
System.out.print("Re-run Program!!");
System.exit (0);
}


}
}





Help need dapat mabasa nya na may same Client Number na nakasave na sa txt file !!!
 
Status
Not open for further replies.

Similar threads

Back
Top