Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. a basic program that performs simple file and mathematical operations. a. Using the file DateParser.java as starter code, program that reads dates from input,

1. a basic program that performs simple file and mathematical operations.

a. Using the fileDateParser.javaas starter code, program that reads 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 thesubstring()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. (20 points)

b.Afterthe program is working as above, modify the program so that it reads all dates from an input fileinputDates.txt(an Example file is part of the GitHub repository that you cloned). (10 points)

c. Modify your program further so that after parsing all dates from the input fileinputDates.txt, it writes out the correct ones into an output file called:parsedDates.txt. (10 points)

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 

40 points total for problem 1

Commit the changes toDateParser.javainto the repository. Don't include the output file. We will use a different inout file for testing your code.

You get an additional 10 points if you make proper use of git by having multiple commits that show the evolution of your code over time so we can basically see your code at stages a., b. and c. (5 points). Make sure you modify the README file inside your repository describing the content (5 points). (seehttps://help.github.com/en/articles/about-readmesfor information about GitHub Readme files)

here is my code so far:

Can you please help me with the input display the date and show me how to do part B&C?

import java.util.Scanner; import java.util.ArrayList; public class DateParser { public static int getMont(String monthOfYear) { int monthNum; switch(monthOfYear) { case "January": monthNum = 01; break; case "February": monthNum = 02; break; case "March": monthNum = 03; break; case "April": monthNum = 04; break; case "May": monthNum = 05; break; case "June": monthNum = 06; break; case "July": monthNum = 07; break; case "August": monthNum = 8; break; case "September": monthNum = 9; break; case "October": monthNum = 10; break; case "November": monthNum = 11; break; case "December": monthNum = 12; break; default: monthNum = 0; break; } return monthNum; } public static void main(String[] args) { // TODO: Read dates from input, parse the dates to find the one // in the correct format, and output in mm/dd/yyyy format } 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions