Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Saturday, July 28, 2012

CJ-6 : Four Calculations-Floating no

Type the programs in NOTEPAD or DOS prompt itself, for Consol Application.
Type in NETBEANS or ECLIPSE for Window Application.
Here after , I am just typing the programs only..to know more about it , refer

Introduction to JAVA 

before doing any JAVA Programs.
***********************************************************************************************
import java.io.*;
class math1
{
public static void main(String args[])
{
 float a,b,result;
 try
 {
  DataInputStream x=new DataInputStream(System.in);
  System.out.println("Enter the first number :");
  a=Float.parseFloat(x.readLine());
  System.out.println("Enter the second number :");
  b=Float.parseFloat(x.readLine());
   result=a+b;
   System.out.println("Addition = "+result);
   result=a-b;
   System.out.println("Subtraction = "+result);
   result=a*b;
   System.out.println("Multiplication = "+result);
   result=a/b;
   System.out.println("Division = "+result);
 }
 catch(Exception e)
 {
 }
}
}
========================================================================= 
Output : 
Enter the first number
12.24
Enter the second number
12.28
Addition=24.52
Subtraction =-0.03999996
Multiplication =150.30719
Division=0.99674267

Refer Four Calculations-Floating no also.




No comments: