subject

LAB: Praising dates Complete main() to read dates from input, one date per line. Each date's format must be as follows: March 1, 1990. Any date not following that format is incorrect and should be ignored. Use the substring() method to parse the string and extract the date. The input ends with -1 on a line alone. Output each correct date as: 3/1/1990.
Ex: If the input is:
March 1, 1990
April 2 1995
7/15/20
December 13, 2003
-1
then the output is:
3/1/1990
12/13/2003
LAB ACTIVITYLAB 11.6.1: Parsing dates
DateParser. java
1 import java. util. Scanner;
2
3 public class DateParser {
4 public static int get MonthAs Int(String monthString) {
5 int monthInt;
6
7 // Java switch/case statement
8 switch (monthString) {
9 case "January" :
10 monthInt = 1;
11 break:
12 case "February":
13 monthInt = 2;
14 break;
15 case "March":
17 monthInt = 3; break:
18 case "April":
19 monthInt = 4;
20 break;
21 case "May":
22 monthInt = 5;
23 break;
24 case "June":
25 monthInt = 6;
26 break;
27 case "July":
28 monthInt = 7;
29 break;
30 case "August":
31 monthInt - 8:
32 break
33 case "September":
34 monthInt = 9;
35 break;
36 case "October":
37 monthInt = 10;
38 break;
39 case "November":
40 monthInt = 11;
41 break;
42 case "December":
43 monthInt = 12;
44 break;
45 default:
46 monthInt = 0;
47 }
48
49 return monthInt;
50 }
51
52 public static void main(String[] args) {
53 Scanner scnr = new Scanner(System. in);
54
55 // TODO: Read dates from input, parse the dates to find the one
56 // in the correct format, and output in m/d/ format
57
58 }
59 }
60

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 19:00, trintrin227
In he example code, what does the title attribute create? a tool tip an element a source a markup
Answers: 1
image
Computers and Technology, 23.06.2019 04:31, mona92
Which of the following is not a way in which trees benefit the environment? a. they remove a significant amount of carbon dioxide from the atmosphere. b. they remove a significant amount of oxygen from the atmosphere. c. their roots hold soil in place, reducing rates of erosion. d. they remove ozone and particulates from the atmosphere. select the best answer from the choices provided a b c d
Answers: 1
image
Computers and Technology, 23.06.2019 09:00, mimithurmond03
Which is the highest level of the hierarchy of needs model? a. humanity b. intrapersonal c. team d. interpersonal
Answers: 1
image
Computers and Technology, 23.06.2019 12:00, xojade
Which of these is an example of an integrated presentation? a. a table created in powerpoint b. an image pasted into powerpoint c. a caption created in powerpoint d. an excel chart pasted into powerpoint
Answers: 1
You know the right answer?
LAB: Praising dates Complete main() to read dates from input, one date per line. Each date's format...

Questions in other subjects:

Konu
Mathematics, 28.05.2020 18:59