-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathProblem6.java
More file actions
74 lines (42 loc) · 1.67 KB
/
Problem6.java
File metadata and controls
74 lines (42 loc) · 1.67 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
62
63
64
65
66
67
68
69
70
71
72
package io.zipcoder;
import java.util.Scanner;
public class Problem6 {
// AM FEATURES WORKING
// PM FEATURES SOON
static MilitarConvention convention = new MilitarConvention ();
// WORKING STILL ON PM FEATURES
public static void main(String[] args) {
int var = 1330 / 100;
System.out.println (var);
Problem6 problem6 = new Problem6 ();
System.out.println ("Enter standard time...");
String timeEntered = problem6.scanner ();
if(problem6.getPmOrAm (timeEntered).equalsIgnoreCase ("am")){
String amTimeResult = convention.amTime (problem6.cleanNumber (timeEntered));
System.out.println (amTimeResult + " Hours");
}else if(problem6.getPmOrAm (timeEntered).equalsIgnoreCase ("pm")){
String pmTimeResult = convention.pmTime (problem6.cleanNumber (timeEntered));
System.out.println (pmTimeResult + " Hours");
}
}
public String getPmOrAm(String userInput) {
return userInput.substring (userInput.length () - 2, userInput.length ());
}
public String getNumberWithOutamOrPm(String userInput) {
return userInput.substring (0, userInput.length () - 2);
}
public String removeSemicolon(String userInput) {
String trim = userInput.trim ();
return trim.replace (":", "");
}
public int numberToInt(String str) {
return Integer.parseInt (str);
}
public int cleanNumber(String str) {
return numberToInt (removeSemicolon (getNumberWithOutamOrPm (str)));
}
public String scanner() {
Scanner scanner = new Scanner (System.in);
return scanner.next ();
}
}