Results 1 to 4 of 4
  1. #1
    maxb is offline Member
    Join Date
    Nov 2008
    Rep Power

    Post 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 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

    in 1 class !

    Can you please help me out ! thanks a lot
    Attached Files Attached Files

  2. #2
    maxb is offline Member
    Join Date
    Nov 2008
    Rep Power


    Here's what I allready have.... right now, all it does is printing the txt file content.

    import java.util.*;
    public class ChiffreAffaire {
    public static void main(String args[])
    // Open the file that is the first
    // command line parameter
    Scanner lectureClavier = new Scanner (;
    System.out.print ("Entrez le nom du fichier des transactions: ");
    String nomFichier =;
    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
    }catch (Exception e){//Catch exception if any
    System.err.println("Error: " + e.getMessage());

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    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.

  4. #4
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Rep Power

    Default 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)

    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

Similar Threads

  1. coding help
    By accies76 in forum New To Java
    Replies: 5
    Last Post: 11-12-2008, 09:15 PM
  2. Help with Invoice app
    By callofthektulu in forum Java Applets
    Replies: 1
    Last Post: 08-08-2008, 04:17 AM
  3. total beginner needs little help
    By asambasamba in forum New To Java
    Replies: 1
    Last Post: 06-18-2008, 05:33 PM
  4. Total Newbie, Be Kind :)
    By dazza-s in forum New To Java
    Replies: 11
    Last Post: 04-26-2008, 10:54 PM
  5. Printing total out
    By denisdoherty in forum New To Java
    Replies: 1
    Last Post: 04-25-2008, 06:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts