This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
class CalculateAccnDist { public static void main(String args[]) { DataInputStream in = new DataInputStream(System.in); float a=0.0f; float u=0.0f;
try { System.out.println("Enter the initial speed in m/sec :"); u=Float.valueOf(in.readLine()).floatValue(); System.out.println("Enter the acceleration of the body :"); a=Float.valueOf(in.readLine()).floatValue(); } catch (Exception e) { } System.out.println(" Time(s) Distance(m)"); for(int t=0;t<=60;t=t+10) { System.out.println(t + ((u*t) + ((a*t*t)/2))); } } }
/* In this above java prog. there is a compiler error,saying : Note: D:\j2sdk1.4.2_11\bin\CalculateAccnDist.java uses or overrides a deprecated API. Note: Recompile with -deprecation for details.
That's not an error - it's a warning. The class file should have been created regardless. It tells you that the DataInputStream.readLine method should no longer be used - it is obsolete. The reason, and what to use instead, are outlined in the javadocs for that method.