Hello! Am new here and i would like you to help dealing with functions in kotlin. When i try to run the function i have created its telling me that variable " gravity " is never used . Here is the function
fun main(args: Array) {var Gravity: Double = -9.81; var InitialVelocity: Double = 0.0; var FailingTime: Double = 10.0; var InitialPosition: Double = 0.0; var FinalPosition: Double = 0.0}
fun GravityCalculator () {
var gravity: Double = -9.81;
// Earth’s gravity in m/s^2
var initialVelocity: Double = 0.0;
var failingTime: Double = 10.0;
var initialPosition: Double = 0.0;
var finalPosition: Double = 0.0;
println( “The object’s position after” + “fallingTime” + “seconds is” + “finalPosition” + “m”);
}
What did you expect to happen?
In the code you wrote you aren’t really using any variable nor calling the only function you defined.
Would you kindly help me on what i should do to use the same variables?
That’s an unsual question to ask. What do you want your code to do?