-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLab04_2_630510606.java
45 lines (37 loc) · 965 Bytes
/
Lab04_2_630510606.java
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
40
41
42
43
44
45
/*
Anawin Athawong
630510606
*/
import java.util.Scanner;
class massange {
private char[] text;
public void setData() {
Scanner input = new Scanner(System.in);
System.out.print("Input text : ");
text = input.nextLine().toCharArray();
}
public void encode() {
for (int i = 0; i < text.length; i++) {
text[i] += 3;
text[i] = Character.toUpperCase(text[i]);
}
}
public void printResult() {
for (int i = 0; i < text.length; i++) {
System.out.print(text[i]);
if ((i + 1) % 3 == 0)
System.out.print(" ");
}
for (int i = 0; i < 3-text.length%3 && text.length%3!=0; i++) {
System.out.print("#");
}
}
}
public class Lab04_2_630510606{
public static void main(String[] args) {
massange t =new massange();
t.setData();
t.encode();
t.printResult();
}
}