Wednesday, April 8, 2026
Main.java

import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner enteredKm = new Scanner(System.in);
    Km2Walk one = new Km2Walk();
    System.out.println("How far is the distance in kilometres? ");
    String kmQuery = enteredKm.nextLine();

   System.out.println(one.kmStepsConverter(Integer.parseInt(kmQuery)));
    System.out.println(one. Message());
  }
}
Km2Walk.java

class Km2Walk {
  public int steps = 1312;
  public int km;

  public String kmStepsConverter(int km){
    return Integer.toString(km * steps) + " steps";
  }
  // create a series of random replies using a Dictionary and Random class in the java.util package.
  public String message(){
    String[] messages = {"Hello", "Hi"};
    int randomNumber = (int) (Math.random() * messages.length);
    return messages[randomNumber];
  }
}
lare (pronounced as LAH-RAY) is a Computer Scientist and Creative Artist who loves creating different ideas with both technology and design. Whenever I'm learning a new technology or programming language, I like to create a journal of my journey - javabyprojects - is my journal for learning java.

0 Comments

Leave a Comment