?
Solved

Points for laax

Posted on 2002-07-05
2
Medium Priority
?
249 Views
Last Modified: 2010-03-31
Your idea in the tokienizer is sound but i can't seem to work anything out correctly.

Nevertheless, I'd like to thank you for your idea...

B)
0
Comment
Question by:DWolve
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
laax earned 300 total points
ID: 7131400
Hi DWolve,
   Thank you .... :-)
Laax.
0
 

Author Comment

by:DWolve
ID: 7131497
public class LineOfCode{
     static int complexCommentFlag;

   public static void main (String [] args) {

String filename=null;

//     Add args=new String[]{"xxx"}; here

     int lineCount = 0;
     int blankSpace = 0;
     int simpleComment = 0;
     int complexComment = 0;
     complexCommentFlag = 0;

try
{
if(args.length==0)
{
     System.out.println("File Required");
}
else if(args.length==1)
{
     filename=args[0];
BufferedReader in = new BufferedReader(new FileReader(filename));
     String line = null;
     
     while (null!=(line=in.readLine()))
     {
          line = line.trim();
          if (line.length()>=0)
          {
               if (line.length()==0)
               {
                    blankSpace++;
               }
               
               if(line.startsWith("//"))
               {
                    simpleComment++;
               }              

               if(line.startsWith("/*"))
               {
                    complexCommentFlag=1;
               }
               if (complexCommentFlag==1)
               {
                    complexComment++;
               }
               if(line.endsWith("*/"))
               {
                    complexCommentFlag=0;
               }

               lineCount++;
          }
     }

     System.out.println("Number of Line = " + lineCount);
     System.out.println("Number of Blank Lines= " + blankSpace);
     System.out.println("Number of Coded Lines= " +lineCount +" - " +blankSpace+" = "+ (lineCount - blankSpace));
     System.out.println("Number of Lines that starts with // = " + simpleComment);
     System.out.println("Number of Lines that within /*--*/ border = " + complexComment);
     System.out.println("Number of Lines of Comment = "+simpleComment+" + "+complexComment+" = "+(complexComment+simpleComment)+"\n");

     System.out.println("Executing File test on "+filename);
     System.out.println("---------------------------------------------------------------");
     System.out.println("Number of Lines in File = " + lineCount);
     System.out.println("Number of Lines of Comment = "+(complexComment+simpleComment));
     System.out.println("Number of Executable Lines = "+(lineCount-complexComment-simpleComment-blankSpace));

}
}
catch (java.io.FileNotFoundException e)
{
     System.out.println("File not found.");
     return;
}
catch (java.io.IOException ioe){
}
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month9 days, 15 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question