Write a program to take several line input from File and, read the lines
and tell
a. whether there is a comment line or not?
b. If there is comment used in the program, is it single line or multiline?
c. Position/line number where comments are used
Hint: Use line break to count and specify position
Answers
Answer:
sorry i don't the answer
Comments are used to make the program more readable by adding the details of the program.
It makes one easy to maintain the process and to find the errors easily.
The comments can be used to provide information or explanation about the variable, method, class, or any statement.
Explanation:
public class abc
{
public static void main(String args[]){
String[] com = new String[50];
Scanner scan = new Scanner(System.in);
int i = 2 ,a=0;
System.out.println("Enter comment");
com[i] = scan.nextLine();
if(com[0].equals("/")){
if(com[1].equals("/")){
System.out.println("comment");
}
else if (com[1].equals("*")){
for(i=2;i<=50; i++){
if(com[1].equals("*") && com[i+1].equals("/") ){
System.out.println("comment");
a=1;
break;
}
else{
continue;}}
if(a==0){System.out.println("not");}
}
else{System.out.println("not");
}
}
else{System.out.println("not");
}
}
}