![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Dec 2004
Posts: 18
Rep Power: 0
![]() |
Homework Problem
// program reads lines from text file adds an inflation rate to it and then drops it into categories. the categories arent important or the format for now. all i want is the thing to read from a txt file and output another text file with the info that it read. once it reads the zero it breaks out.
================= 299.99 Television 159.95 Microwave Oven 512.22 Refrigerator 0 ================== import java.io.*; class S1 { public static void main(String[] args) throws IOException { final float INFLATION = .025f FileReader file1 = new FileReader("G:\\java programs\\S1Data.txt"); BufferedReader inputfile = new BufferedReader(file1); FileWriter file2 = new FileWriter("G:\\java programs\\S1Output.txt"); PrintWriter outputFile = new PrintWriter(file2); String name; float price; price = new Float(inputFile.readLine()).floatValue(); while(price != 0) { price += price * INFLATION; name = inputFile.readLine(); outputFile.println(price + " " + name); price = new Float(inputFile.readLine()).floatValue(); } inputFile.close(); outputFile.close(); } } problem is in line 8 FileReader file1 = new FileReader("G:\\java programs\\S1Data.txt"); i just cant figure it out. please obi won kenobi your my only hope ![]() Last edited by Cup O' Java; Feb 10th, 2005 at 9:45 PM. |
|
|
|
|
|
#2 |
|
Newbie
Join Date: Dec 2004
Posts: 18
Rep Power: 0
![]() |
ok nevermind Machiavelli went ape $hit on this little problem I had.
thanks man, cat knows his $hit |
|
|
|
|
|
#3 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Heh. He does, at that. Just out of interest, what was the final product?
|
|
|
|
|
|
#4 |
|
Newbie
Join Date: Dec 2004
Posts: 18
Rep Power: 0
![]() |
oh im sorry im so late at getting back. since he helped me i didnt know anyone else was checking. but here it is.
Last edited by Cup O' Java; Feb 15th, 2005 at 11:12 PM. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|