+ 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

25th Nov 2020, 11:09 AM
STOP
STOP - avatar
12 odpowiedzi
+ 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..
25th Nov 2020, 11:59 AM
Jayakrishna 🇮🇳
+ 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..
25th Nov 2020, 12:14 PM
Jayakrishna 🇮🇳
+ 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.
26th Nov 2020, 3:25 AM
Tibor Santa
Tibor Santa - avatar
+ 1
Do you mean explanation? Why can't you comment? Is this not your code??
25th Nov 2020, 11:53 AM
Jayakrishna 🇮🇳
0
I will send the codes under this message
25th Nov 2020, 11:10 AM
STOP
STOP - avatar
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)+"%"); } }
25th Nov 2020, 11:10 AM
STOP
STOP - avatar
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"); } } }
25th Nov 2020, 11:11 AM
STOP
STOP - avatar
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); } }
25th Nov 2020, 11:11 AM
STOP
STOP - avatar
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
25th Nov 2020, 11:54 AM
STOP
STOP - avatar
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
25th Nov 2020, 12:01 PM
STOP
STOP - avatar
0
In java you can use // for single line comment You can use /* */ for multiline comments
26th Nov 2020, 4:43 PM
QUANTUMSPARK1
QUANTUMSPARK1 - avatar