View Code of Problem 104

import java.util.Scanner;
public class Main {
	    public static void main(String[] args) {
	        Scanner scanner=new Scanner(System.in);
	       while(scanner.hasNext()) {
	    	   		int n = scanner.nextInt() * 1000;
	    	   		int v1 = scanner.nextInt();
	    	   		int v2 = scanner.nextInt();
	    	   		int t = scanner.nextInt();
	    	   		if(v1<=v2) {
	    	   			System.out.println("NO");
	    	   		}else {
	    	   			if(t*(v1-v2)>=n) {
	    	   				double t1 = (double)n/(v1-v2);
	    	   				System.out.println(String.format("%.2f", t1));
	    	   			}else {
	    	   				System.out.println("NO");
	    	   			}
	    	   		}
	       }
	        scanner.close();
	    }
	
}

Double click to view unformatted code.


Back to problem 104