Skip to content

Commit

Permalink
Create Comments.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinctofel authored Jan 17, 2025
1 parent 4178999 commit 7839720
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Programming/Java/Comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
A single-line comment starts with // and includes all the following text on that line. Single-line comments commonly appear after a statement on the same line.

---

A multi-line comment starts with /* and ends with */, where all text between /* and */ is part of the comment. A multi-line comment is also known as a block comment.

---

Example:

```java

import java.util.Scanner;

/*
This program calculates the amount of pasta to cook, given the
number of people eating.
Author: Andrea Giada
Date: May 30, 2017
*/

public class PastaCalculator {
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
int numPeople; // Number of people that will be eating
int totalOuncesPasta; // Total ounces of pasta to serve numPeople

// Get number of people
System.out.println("Enter number of people: ");
numPeople = scnr.nextInt();

// Calculate and print total ounces of pasta
totalOuncesPasta = numPeople * 3; // Typical ounces per person
System.out.println("Cook " + totalOuncesPasta + " ounces of pasta.");
}
}
```

0 comments on commit 7839720

Please sign in to comment.