Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Assignment

Comments are REQUIRED; flow charts and pseudocode are NOT REQUIRED.

Directions

The files must be called

LiFiTime.java (Time class file)

The files must be called as specified above, (LiFi = Your Last Initial Your First Initial)

Proper coding conventions required the first letter of the class start with a capital letter and the first letter of each additional word start with a capital letter.

Only submit the .java files needed to make the program run. Do not submit the class files or any other files.

Style Components

Include properly formatted prologue, comments, indenting, and other style elements as shown in Chapter 2 starting page 64 and Appendix 5 page 881-892.

Topics covered in chapter

Topics with * are covered in this assignment.

*Exceptions and Exception Messages
*try / catch
*checked and unchecked exceptions
*generic catch block
*throws

Basic Requirements

Write a program that validates time when entered. It should output the time as either AM or PM or the error if entered incorrectly.

See sample output below.

LiFiUnit6Ch15.java

• Driver class should loop until "q" is entered to quit
• If enter is not "q", then create an instance of the LiFiTime object passing the entry as an argument
• If no error

o Print time by calling print method in LiFiTime class
• If error
o Print error message (see sample)

LiFiTime.java class

Time objects should store the time in 2 integer instance variables, hour and minute, and include a string variable to hold the error. This should be initialized with null.

LiFiTime Constructor:

• Receive time as a string
• Perform error checking to ensure time was entered in proper format to include a color (:) between the digits
• Use indexOf and substring to separate the time string into the appropriate instance variables
• Check hour to ensure is between 1 and 23
• Check minute to ensure is between 0 and 59
• If an error occurs, change the error instance variable to reflect the error (see sample)

print method:

• Include a separate method to print the date using printf to output time in digits for the hour and 2 digits for the minutes
• Print AM if before noon and PM if after noon. Do NOT print in military time

getError method:
• Include a getError method that returns the error instance variable to the print method

NOTE: Complete your activity and submit it by clicking "Submit Assignment"

Sample

Your output will vary based on the random numbers generated.

Sample session (requires no user input):
Enter time in the form mm:dd ("q" to quit): 5:20
05:20 AM
Enter time in the form mm:dd ("q" to quit): 05:20
05:20 AM
Enter time in the form mm:dd ("q" to quit): 05:80
Invalid minute entered: 80

Enter time in the form mm:dd ("q" to quit): 15:20
03:20 PM
Enter time in the form mm:dd ("q" to quit): 25:20
Invalid hour entered: 25
Enter time in the form mm:dd ("q" to quit): 0520
Invalid separator entered: :
Enter time in the form mm:dd ("q" to quit): q

Java, Programming

  • Category:- Java
  • Reference No.:- M91754952
  • Price:- $80

Guranteed 48 Hours Delivery, In Price:- $80

Have any Question?


Related Questions in Java

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Simple order processing systemquestion given the classes

Simple Order Processing System Question: Given the classes Ship (with getter and setter), Speedboat, and SpeedboatTest. Answer the following questions: Refine the whole application (all classes) and create Abstract class ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As