java comment | SoloLearn: Learn to code for FREE!

+2

java comment

Please help me to write comments explaining the code, I wrote the code correctly, but I cannot express and explain what I did

11/25/2020 11:09:46 AM

STOP

12 Answers

New Answer

+4

There are many different styles of comments used by programmers. Some organisations have formal design guides and software standards documents which specify the indentation, layout and comment style. for example... NASA C++ Coding Standards and Style Guide https://ntrs.nasa.gov/citations/20080039927 Java also has JavaDoc comments. These are special comments used to produce source code documentations in html format and can be of immense benefit. https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html For your own code just pick a style you like and stick with it. Just be aware that if you submit code to a major project or organisation it may need to be it their style rather than your own. See also: https://dev.to/scottshipp/which-java-code-style-should-you-use-1k5a

+2

You can add in your own language.. Then use Google translate to write in English.. There is no need to add only in English.. If you don't understand some statements then ask about that specific statements.. Try to add your own as much as possible by you..

+2

STOP I only know comments is for our code understanding.. Professionally way? no idea specifically.. I can add my way in English only.. I don't have professional experience. Still a learner. May you need ask the mods may be.. I think some one else can answer about that may be.. If you want I can delete my answers, because others think it is answered.. Or better you may post new question and delete this.. Share code links in description instead of as a answers place.. Hope it helps..

+2

Comments can be useful, but use them only when they add value. As Robert Martin said, well-written code explains itself. So in the comment you should NOT write WHAT you did, but rather, WHY you did it [that way]. Comments are good for reminding you later of your thought process. Also keep in mind that other people will read and maybe modify your code, so comments should give them some guidance, especially when the intention is not clear.

+1

Do you mean explanation? Why can't you comment? Is this not your code??

0

I will send the codes under this message

0

import java.util.Scanner; public class HW4 { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.println("Enter your name:"); String name=input.nextLine(); System.out.println(" Hi "+name.toUpperCase() + " your name contains " + name.length () + "letters." ); System.out.println("Enter the quality point at your University:"); double qualityPoint=input.nextDouble(); System.out.println("Enter your GPA:"); double GPA=input.nextDouble(); double average=(GPA/qualityPoint)*100; System.out.println("Your average in percentage is: "+Math.round(average)+"%"); } }

0

import java.util.Scanner; public class HW5Sec1 { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.println("Enter your name: "); String name=input.nextLine(); for(int i=0;i<name.length();i++) { if(name.charAt(i)=='a' ||name.charAt(i)=='e' ||name.charAt(i)=='i' ||name.charAt(i)=='o' ||name.charAt(i)=='u' ||name.charAt(i)=='A' ||name.charAt(i)=='E' ||name.charAt(i)=='I' ||name.charAt(i)=='O' ||name.charAt(i)=='U' ) System.out.println(name.charAt(i)+" is vowel"); else if((name.charAt(i)>='a' && name.charAt(i)<='z' )||(name.charAt(i)>='A' && name.charAt(i)<='Z')) System.out.println(name.charAt(i)+" is consonant"); } } }

0

import java.util.Scanner; public class HW5Sec2 { public static void main(String[] args) { int grade[]=new int[5]; Scanner input=new Scanner(System.in); System.out.println("Enter student's grade in 5 courses:"); for(int i=0;i<5;i++) { System.out.print("Enter grade-"+(i+1)+": "); grade[i]=input.nextInt(); } int min=grade[0],max=grade[0]; for(int i=1;i<5;i++) { if(max<grade[i]) max=grade[i]; if(min>grade[i]) min=grade[i]; } System.out.println("Highest grade is = "+max); System.out.println("Lowest grade is = "+min); } }

0

Jayakrishna🇮🇳 Because I struggle to express speech in the English language, although this code I wrote, but I cannot express in English an expression that explains it

0

Jayakrishna🇮🇳 I know that I can translate the speech or write it in my own language, but I want to learn from the professional methods of writing comments, because Google Translate does not translate professionally

0

In java you can use // for single line comment You can use /* */ for multiline comments