## 1.使用for循環統計輸入的行數

Scanner console = new Scanner(System.in);
int count = 0;
for (int i = 0; i < 10; i++)
{
if (console.hasNextInt())
count++;
console.nextLine();
}
System.out.println(count);
Create a Scanner object to read data from the console.
Store the number of numbers in the count variable.
Loop from 0 to 10 (not including 10).

If a number is entered,
then increase count by one.
Read a line from the console and don't save it anywhere.

Display the calculated count on the screen.

## for2. 使用循環計算階乘

int f = 1;
for (int i = 1; i <= 10; i++)
f = f * i;
System.out.println(f);
We store the product of numbers in the f variable.
Loop from 1 to 10 (inclusive).
Multiply f by the next number (save the result in f).
Display the calculated amount on the screen.

## 3.使用for循環在屏幕上繪製

for (int i = 0; i < 10; i++)
{
int starCount = 10 - i;
for (int j = 0; j < starCount; j++)
System.out.print("*");
System.out.println();
}
Loop through the lines (there should be 10 lines in total).

Calculate how many asterisks should be in the line.
Loop over the individual asterisks
(display starCount asterisks).
Move the cursor to the next line so the lines are separate.