Results 1 to 4 of 4
- 11-21-2008, 05:29 PM #1
Member
- Join Date
- Nov 2008
- Posts
- 5
- Rep Power
- 0
Need Help for coding invoice total
Hi everyone,
I need to make a program for school which reads a provided txt file. The file is in attachment.
The file name has to be asked to user.
The file that has the information has numbers like this
1442945365 88 4,83 3
Which represent that :
| product label | unit sold | unit price | taxe type
Tax type:
0 : no tax
1 : TPS et TVQ (both taxes)
2 : TPS
3 : TVQ
TPS: 5% from the price
TVQ: 7.5% of (price + tps)
Code the algorithm that solves the following problem in a program entitled ChiffreAffaire.java. The display of this program is specified by the following example.
File name: ListeTrans0.TXT
Total without taxes : 92.0
Total TPS : 2.5
Total TVQ : 4.575
Total with taxes : 99.075
need to use this only:
if . . . else
switch
while
Hasnext
in 1 class !
Can you please help me out ! thanks a lot
- 11-22-2008, 02:37 PM #2
Member
- Join Date
- Nov 2008
- Posts
- 5
- Rep Power
- 0
Here's what I allready have.... right now, all it does is printing the txt file content.
import java.util.*;
import java.io.*;
public class ChiffreAffaire {
public static void main(String args[])
{
try{
// Open the file that is the first
// command line parameter
Scanner lectureClavier = new Scanner (System.in);
System.out.print ("Entrez le nom du fichier des transactions: ");
String nomFichier = lectureClavier.next();
FileInputStream fstream = new FileInputStream(nomFichier);
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
System.out.println (strLine);
}
//Close the input stream
in.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
}
-
OK, so you are successfully reading in each line. Now tell me if you know of any good ways to split the information on each line into the information you need: the product label (doesn't seem to be important for this project), units sold, unit price, etc? In other words, if you are going to break this project down into steps, this would be the next step correct? so let's work on it.
- 11-22-2008, 04:22 PM #4
suggestions ...
Here's the String class and it's methods:
String (Java Platform SE 6)
Here another helpful link:
Methods of the Pattern Class (The Java™ Tutorials > Essential Classes > Regular Expressions)
Luck,
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
Similar Threads
-
coding help
By accies76 in forum New To JavaReplies: 5Last Post: 11-12-2008, 08:15 PM -
Help with Invoice app
By callofthektulu in forum Java AppletsReplies: 1Last Post: 08-08-2008, 04:17 AM -
total beginner needs little help
By asambasamba in forum New To JavaReplies: 1Last Post: 06-18-2008, 05:33 PM -
Total Newbie, Be Kind :)
By dazza-s in forum New To JavaReplies: 11Last Post: 04-26-2008, 10:54 PM -
Printing total out
By denisdoherty in forum New To JavaReplies: 1Last Post: 04-25-2008, 06:40 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks