akmalrashd / SC025-Matrix

From & For Matriculations Physical / Computer Science Students
0 stars 0 forks source link

Question 2 - Sequence - SC025 #1

Open akmalrashd opened 1 year ago

akmalrashd commented 1 year ago

Calculate and display the velocity of a car if velocity is equal to distance divided by time taken. Display “Over Speed Limit” if velocity exceeded 110 km/h.

akmalrashd commented 1 year ago
import java.util.Scanner; 
public class Day2 
{ 
    public static void main (String[]args) 
    { 
        Scanner akmal = new Scanner(System.in); 

        double distance , timeTaken, velocity; 

        System.out.print("Enter distance (m): " ); 
        distance = akmal.nextDouble(); 
        System.out.print("Enter time taken (s): "); 
        timeTaken = akmal.nextDouble(); 

        velocity = distance / timeTaken;

        System.out.println("Your velocity is " + velocity + "m/s"); 

        if ( velocity >= 110)
            System.out.println("Over Speed Limit"); 

    } 
}