Menu
Question Index
...


Write a program to update the missing value of the four parameters like train length, platform length, time taken to cross a pole, time taken to cross a platform. A class containing the information of any three parameters is passed.
The value of missing parameter will be -1.

Input Output
( -1, 60, 100, 200 ) 20
( 15, -1, 150, 150 ) 30
( 40, 80, -1, 400 ) 400
( 15, 30, 150, -1 ) 150

class TrainCrossingTime

{    public static void main(String s[])
    {
        double result = calculateVariable( -1, 60, 100, 200 );
        System.out.println("The time taken to cross a pole is " + result);

    }


public static double calculateVariable( double poleCrossingTime, double platformCrossingTime, double trainLength, double platformLength )
{
//Write a code here to calculate the missing parameter value and return it.
}
}

Doubts

Problems

Topic: if else Vs switch Performance In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App