The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 327 Weeks Ago, 6 Days Ago |
| Questions Answered: | 12843 |
| Tutorials Posted: | 12834 |
MBA, Ph.D in Management
Harvard university
Feb-1997 - Aug-2003
Professor
Strayer University
Jan-2007 - Present
Design, write in Java, test and document a program to calculate the number of minutes between one time and another. Here are some examples:
TIME DIFFERENCE
Enter first time ( hh: mm a/pm): 12:56pm Enter second time ( hh: mm a/pm): 1:03pm
The difference is 7 minutes
Do you wish to continue (Y/N)? Y
TIME DIFFERENCE
Enter first time ( hh: mm a/pm): 1:03pm Enter second time ( hh: mm a/pm): 12:56pm
The difference is 1433 minutes
ICT104 Assignment 1 4 Do you wish to continue (Y/N)? Y
TIME DIFFERENCE
Enter first time ( hh: mm a/pm): 1:03pm Enter second time ( hh: mm a/pm): 12:65pm
ERROR: the second time is not valid
Do you wish to continue (Y/N)? Y
TIME DIFFERENCE
Enter first time ( hh: mm a/pm): 8:30 am Enter second time ( hh: mm a/pm): 5:30 pm
The difference is 540 minutes
Do you wish to continue (Y/N)?
N
The times are to be entered (on one line) in the 12 hour format with hours (1-2 digits), colon, minutes (2 digits) and then the string “am” or “pm”. You may also allow spaces.
The program should be well-structured and should have a reasonable set of methods in addition to the main method. It should use a good coding style, proper indentation, meaningful identifiers and appropriate comments throughout.
The program should also include a method (eg, StudentInfo( )) to output your student details (name, student number, mode of enrolment (i.e., internal or external), tutor name, tutorial attendance day and time) at the start of program results.
Devise suitable test data to test all sections of program code. The test data together with test results should be submitted as part of your external documentation.
Hint:
1. You may consider using the following methods from the Java String class: indexOf(int char) indexOf(int char, int fromIndex) indexOf(String str) indexOf(String str, int fromIndex) to work out the index position of a character or a substring within a string;
2. and then use substring(int beginIndex, int endIndex) substring(int beginIndex) to extract the different parts of a string;
3. and then use wrapper Integer class method Integer.parseInt(String str) to convert the string such as “12” into its numerical representation (see pages 447-452 of Savitch 7th Edition or Topic 4 Lecture notes).
-----------