Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Internet Programming (Java) Need Help  RSS feed

 
john kudas
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to create a Java Application to allow local user to enter and save the following information into a serial file �BankRec.txt�.

*need to use things like : FileReader , FileWriter , BufferedReader , FileReader , PrintWriter

eg:
Account Number : B001
Name : Alison Ng
Account Type : Saving
Amount : 1000.00


Account Number : B002
Name : Bob Tan
Account Type : Current
Amount : 3000.00


how do i edit the source code to the question?
using JOptionPane.
can anyone help me? thanks

import java.io.*;

public class program
{
public static void main(String[] args) throws IOException
{
String data;
BufferedReader input=
new BufferedReader(
new InputStreamReader(System.in));

PrintWriter output =
new PrintWriter(new FileWriter("BankRec.txt"));
for (int i=1; i<5; i++)
{
data ="";

System.out.print("Enter Account Number: ");
data = data + " " + input.readLine();
//output.println(data);

System.out.print("Enter Name: ");
data = data + " " + input.readLine();
//output.println(data);

System.out.print("Enter Account Type: ");
data = data + " " + input.readLine();
//output.println(data);

System.out.print("Enter Amount: ");
data = data + " " + input.readLine();

output.println(data);

output.flush();
}
output.close();
}
}
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

On your way in you may have missed that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.

A'm not sure what exactly you're asking. This is the JSP forum, but there seems to be nothing in the question about web apps. Then you mention JOptionPane (a Swing class), yet the code contains no GUI. Can you elaborate on what you're trying to do? Instead of reading from System.in, do you want a GUI that allows the user to enter the data? If so, where are you stuck implementing that? Or do you not know where to begin at all?
 
john kudas
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am stuck and don't know how to begin at all...
what should i do?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you familiar with Swing at all? Have you worked through the Sun Java Tutorial, which has an extensive chapter about Swing? That would be a good starting point.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you write the code you included? It looks like it ought to do one small part of the problem ok. And one small part at a time is a good way to work. Let's forget everything else for the moment ... does this much run ... does it do what you want it to do?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!