• Post Reply Bookmark Topic Watch Topic
  • New Topic

FileReader and FileWriter  RSS feed

 
kerwin john abrinica
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Guys .

//need help of this Activity if you would mind ..


Sales.txt

Day 1, Product 1, 5000
Day 1, Product 2, 5859.99
Day 1, Product 3, 6001.75
Day 2, Product 1, 5555
Day 2, Product 2, 7750.99
Day 2, Product 3, 6000
Day 3, Product 1, 5877.85
Day 3, Product 2, 5559.30
Day 3, Product 3, 6578.98

//I want to make the Sales.txt into this

TITLE : FILEreader and FILEwriter ..

Create a program named SalesSummary that reads its input from a text file named sales.txt. The program will then have a method that will separate and display the tokens in this table format below:

Product 1 Product 2 Product 3

Day 1 5000 5859.99 6001.75
Day 2 5555 7750.99 6000
Day 3 5877.85 5559.30 6578.98

Aside from displaying the sales write your output in a text file named salesFile.txt

//my instructor said that if your run it in JAVA the data will store in Notepad . I need some guides of you Guys ..

THANKS

 
Mohamed Sanaulla
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For FileReader FileWriter you can start with this

 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

A good place to start is at the API documentation. Lookup the classes FileReader and FileWriter; they are in the java.io package. These classes contain methods to read and write text from and to files. Start by writing a small program that uses FileReader to read the content of the input text file, and print it to the console (with System.out.println()). When you learn how to use FileReader, try to make a program that also uses FileWriter to complete the task.
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should also search this forum, because somebody else is having problems with the same exercise.
 
Noam Ingalls
Ranch Hand
Posts: 60
Chrome Firefox Browser Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would suggest you look up methods of storing the input data too... Try looking at the Java APIs for List implementations.
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need a Product class and a Day class.
 
brando brandido
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, kerwin, my classmate! LOL!

here is my code,

to give you idea, run this code and you'll get the first line with the amount.



finish it ok? LOL! and don't just copy all the codes or else our teacher will beat us. LOL!

the above code is not properly coded and so noob but alteast the idea is there.

----

i am a beginner in java prog too! cheers!
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
brando brandido wrote:Hey, kerwin, my classmate! LOL!
We thought there were several people in the same class because several people have asked such similar questions.
here is my code, . . .
I am afraid I shall link you to what Joanne Neal wrote. Joanne’s good; you ought to take her advice.

Correction: Joanne’s very good.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:
brando brandido wrote:Hey, kerwin, my classmate! LOL!
We thought there were several people in the same class because several people have asked such similar questions.
here is my code, . . .
I am afraid I shall link you to what Joanne Neal wrote. Joanne’s good; you ought to take her advice.

Correction: Joanne’s very good.

You're only saying that because my advice was to follow yours and Fred's advice.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!