Tuesday, July 12, 2011

3 part sum of three number divide by fourth number

This java program is able to calculate result in decimal value, you only have to change 8 line of previous program from(double A,B,C,D,total;) to ( Float A,B,C,D,total;).
In this program we take four input number from user -A, B, C, D.
hear A, B, C are added and divided by D,this is the hole detail of program. 

source code
  1. import java.io.*;
  2. class sum_of_three_no_divide_by_fourth_no
  3. {
  4.     public static void main(String[] args)throws IOException
  5.     {
  6.         InputStreamReader ir=new InputStreamReader(System.in);
  7.         BufferedReader br=new BufferedReader(ir);
  8.         Float A,B,C,D,total;
  9.         System.out.println("Eter no1");
  10.         A=Float.parseFloat(br.readLine());
  11.         System.out.println("Eter no2");
  12.         B=Float.parseFloat(br.readLine());
  13.         System.out.println("Eter no3");
  14.         C=Float.parseFloat(br.readLine());
  15.         System.out.println("Eter no4");
  16.         D=Float.parseFloat(br.readLine());
  17.         total=(A+B+C)/D;
  18.         System.out.println("Total="+total);
  19.        
  20.                 }
  21. }

No comments:

Post a Comment