This java program is able to calculate result in decimal value, you only have to change 8 line of previous program from(int A,B,C,D,total;) to (double 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
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
- import java.io.*;
- class sum_of_three_no_divide_by_fourth_no
- {
- public static void main(String[] args)throws IOException
- {
- InputStreamReader ir=new InputStreamReader(System.in);
- BufferedReader br=new BufferedReader(ir);
- double A,B,C,D,total;
- System.out.println("Eter no1");
- A=Double.parseDouble(br.readLine());
- System.out.println("Eter no2");
- B=Double.parseDouble(br.readLine());
- System.out.println("Eter no3");
- C=Double.parseDouble(br.readLine());
- System.out.println("Eter no4");
- D=Double.parseDouble(br.readLine());
- total=(A+B+C)/D;
- System.out.println("Total="+total);
- }
- }
No comments:
Post a Comment