-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBob.java
More file actions
124 lines (102 loc) · 3.81 KB
/
Copy pathBob.java
File metadata and controls
124 lines (102 loc) · 3.81 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import java.util.Scanner;
public class Bob {
public static void main (String[] args) {
Scanner myScanner = new Scanner(System.in);
// System.out.println("*************************");
// System.out.println("Welcome to Bob Simulator!");
// System.out.println("*************************");
// System.out.println("Start typing to speak with Bob!");
//
// String userInput;
// userInput = myScanner.nextLine();
//
// while (!userInput.equalsIgnoreCase("exit")) {
// if (userInput.equals("")) {
// System.out.println("Fine. Be that way!");
// } else if (userInput.endsWith("!")) {
// System.out.println("Whoa, chill out!");
// } else if (userInput.endsWith("?")) {
// System.out.println("Sure.");
// } else {
// System.out.println("Whatever.");
// }
// userInput = myScanner.nextLine();
// }
System.out.println("Please enter date in MM/DD/YYYY format.");
String Date = myScanner.nextLine();
String Month = Date.substring(0,2);
String Day = Date.substring(3,5);
String Year = Date.substring(6);
System.out.println(Month);
System.out.println(Day);
System.out.println(Year);
switch (Month) {
case "01":
Month = "January";
System.out.printf("%s %s, %s", Month, Day, Year);
break;
case "02":
Month = "February";
System.out.printf("%s %s, %s", Month, Day, Year);
break;
case "03":
Month = "March";
System.out.printf("%s %s, %s", Month, Day, Year);
break;
case "04":
Month = "April";
System.out.printf("%s %s, %s", Month, Day, Year);
break;
case "05":
Month = "May";
System.out.printf("%s %s, %s", Month, Day, Year);
break;
case "06":
Month = "June";
System.out.printf("%s %s, %s", Month, Day, Year);
break;
case "07":
Month = "July";
System.out.printf("%s %s, %s", Month, Day, Year);
break;
case "08":
Month = "August";
System.out.printf("%s %s, %s", Month, Day, Year);
break;
case "09":
Month = "September";
System.out.printf("%s %s, %s", Month, Day, Year);
break;
case "10":
Month = "October";
System.out.printf("%s %s, %s", Month, Day, Year);
break;
case "11":
Month = "November";
System.out.printf("%s %s, %s", Month, Day, Year);
break;
case "12":
Month = "December";
System.out.printf("%s %s, %s", Month, Day, Year);
break;
}
System.out.println("Please enter a sentence below:");
String sentence = myScanner.nextLine();
sentence = sentence.toLowerCase();
int vowels = 0;
int consonants = 0;
for (int i = 0; i < sentence.length(); i++)
{
if (sentence.charAt(i) == 'a' || sentence.charAt(i) == 'e' || sentence.charAt(i) == 'i'
|| sentence.charAt(i) == 'o' || sentence.charAt(i) == 'u') {
vowels++;
}
else if (sentence.charAt(i) >= 'a' && sentence.charAt(i) <= 'z')
{
consonants++;
}
}
System.out.printf("Number of vowels: %d", vowels);
System.out.printf("Number of consonants: %d", consonants);
}
}