-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPhoneFormat.java
More file actions
61 lines (45 loc) · 1.27 KB
/
Copy pathPhoneFormat.java
File metadata and controls
61 lines (45 loc) · 1.27 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
51
52
53
54
55
56
57
58
59
60
61
// Jonathan Rumley
// CSC161-101
// Lab 1 - String Manipulation
import java.util.Scanner;
public class PhoneFormat
{
static Scanner userInput = new Scanner(System.in);
private static String pNum1;
public static void main(String[] args)
{
System.out.println("Greetings Earthling,\n\nPlease enter your phone number below in the following format (XXX)-XXX-XXXX.\n");
getPNum();
}
public void setPNum(String pN) {
pNum1 = pN;
}
public static String getPNum() {
String pNum1 = userInput.nextLine();
//String[] pNumFormat = "".split("");
if(pNum1.matches("\\(\\d{3}\\)-\\d{3}-\\d{4}")) {
//pFormat();
cDown(10);
System.out.println("Valid Phone Number. Thank you.");
}
else {
System.out.println("\nInvalid Phone Number Formatting: Follow (XXX)-XXX-XXXX\n");
}
return pNum1;
}
//public static String[] pFormat() {
//String[] pLoop = pNum1.split("($1)-$2-$3");
//for(int i = 0; i < pLoop.length; i++)
//System.out.println(pLoop[i]);
//return pLoop;
//}
public static void cDown(int n) {
if(n <= 0)
System.out.println("You're a winner!!!\nBe proud you're a winner.\n\n");
else
{
System.out.println(n);
cDown(n - 1);
}
}
}