Create a class called Distance that includes two private data members feet (type int) and inches (type float). Use a method setData to set values to instance variables. Provide a method display that displays the feet and inches, a member function addDistance for adding two distances, and a member function compareDistance for comparing two distances. Implement your program in Java.


Updated: Oct. 3, 2023 — Training Time: 2 minutes
Overseen by: Archangel Macsika
Topic:Generic - Java Programming

Difficulty: Advance.

Companies who previously asked this: -.

Objective: Create a class called Distance that includes two private data members feet (type int) and inches (type float). Use a method setData to set values to instance variables. Provide a method display that displays the feet and inches, a member function addDistance for adding two distances, and a member function compareDistance for comparing two distances. Implement your program in Java.

Input: Numbers to serve as distance values.

Expected Output: Result will vary based on the user input.

Sikademy Solution

Was this training resource helpful?