• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

FileReader and FileWriter

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For FileReader FileWriter you can start with this

 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 75857
361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should also search this forum, because somebody else is having problems with the same exercise.
 
Ranch Hand
Posts: 60
Firefox Browser Chrome Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 75857
361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you need a Product class and a Day class.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 75857
361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic