KeeganT

Ch4Ex1

Feb 5th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. package ch4ex1;
  2. import java.util.Scanner;
  3.  
  4. public class Ch4Ex1
  5. {
  6.     public static void main(String[] args)
  7.     {
  8.         Scanner sc=new Scanner(System.in);
  9.         System.out.print("Enter a  time less than 4.5 seconds: ");
  10.         double s=sc.nextDouble();
  11.         while(s>4.5)
  12.         {
  13.             System.out.print("Invalid number. Please enter a time less than 4.5 seconds: ");
  14.             s=sc.nextDouble();
  15.         }
  16.         double h=100-4.9*(s*s);
  17.         System.out.println("The height of the object is: "+h);
  18.     }
  19. }
Add Comment
Please, Sign In to add comment