Coding 3 basic Java programs

Coding 3 basic Java programs

Note: Please make sure to add comments for each coding step. Also, make sure that this is your original work.

Program #1:

. Define (create) a class named LinearMeasure that stores a length in feet and inches, in which both are stored as integer types. Include in the class,

  • An alternator constructor (that is passed a specific number of feet and inches)
  • Getters and setters (for both feet and inches)
  • An appropriate toString method (returning a string of the form 2 ft. 10 ins.)
  • A method named getTotalInches that returns the length as inches (e.g., if the length
    is stored as 4 ft. and 6 ins., would return 54 ins.)
  • An add method that is passed another LinearMeasure object, and returns a
    LinearMeasure object containing the total of both lengths.
  • ———————————
  • Program #2: Write a simple (main) program that does the following:
  • Prompts the user for a given length in feet and inches
  • Creates an object of type LinearMeasure named length1 of that length
  • Prompts the user for another length in feet and inches
  • Creates another object of type LinearMeasure named length2 of that length
  • Displays the sum of the two lengths in the following form:
    The total length is 6 ft. 8 ins.

—————————————————–

program #3 :

Had them develop a HeightAndWeight class very similar to the XYCoord class from the lecture slides. The class was to have an appropriate constructor, setters and getters, and a print method that would print “5 ft 7 ins. 140 lbs.”.

The other part of the lab is to write a test driver for it, i.e., a separate main program that creates an object of type HeightAndWeight and shows that all of the methods work.

"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.


Discount Code: CIPD30



Click ORDER NOW..

order custom paper