-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlotWord.java
More file actions
50 lines (49 loc) · 1.13 KB
/
PlotWord.java
File metadata and controls
50 lines (49 loc) · 1.13 KB
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
46
47
48
49
50
import java.util.Scanner;
public class PlotWord {
public static void main(String[]args)
{
PlotWord p1 = new PlotWord();
p1.runner();
}
public void runner()
{
Scanner s1 = new Scanner(System.in);
System.out.print("\n\n\n");
System.out.println("Please enter a coordinate: ");
int xc = s1.nextInt();
int yc = s1.nextInt();
System.out.print("What is the word you would like to plot? ");
s1.nextLine();
String str = s1.nextLine();
plotPoints(xc, yc,str);
System.out.print("\n\n\n");
}
public void plotPoints(int x1, int y1, String str)
{
int newY = (y1*-1)+10;
int newX = 0;
if(x1 <=0) {
newX = (x1*2)+20;
} else {
newX = (x1*2)+18;
}
for(int y=0;y<21;y++)
{
for(int x=0;x<41;x++)
{
if(x == newX && y == newY)
{
System.out.print(str +" ");
x = x + str.length();
} else if (y == 10) {
System.out.print("-");
} else if (x == 20) {
System.out.print("|");
} else {
System.out.print(" ");
}
}
System.out.println();
}
}
}