-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise06_12.java
More file actions
39 lines (30 loc) · 901 Bytes
/
Copy pathExercise06_12.java
File metadata and controls
39 lines (30 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.util.Scanner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author jorda
*/
public class Exercise06_12 {
public static void main(String[] args) {
char ch1 = '1';
char ch2 = 'z';
int numberPerLine = 10;
printChars(ch1, ch2, numberPerLine);
}
public static void printChars(char ch1, char ch2, int numberPerLine){
int iCh1 = (int)ch1;
int iCh2 = (int)ch2;
int lineCTRL = 1;
for (int i = ch1; i <= ch2; i++) {
if(lineCTRL % numberPerLine != 0)
System.out.print((char)i + " ");
else
System.out.println((char)i);
lineCTRL++;
}
}
}