. Write a program to find the sum of three fractional numbers and print the final result in java
Answers
Answered by
6
Answer:
import java.util.*;
class abc{
public static void main (String ar []){
Scanner sc=new Scanner (System.in);
System.out.println("Enter 3 fractional numbers");
double a=sc.nextDouble();
double b=sc.nextDouble();
double c=sc.nextDouble();
double s=0.0;
s=a+b+c;
System.out.println("Sum="+s);
}
}
Logic:-
- Accept 3 fractional numbers as input
- Initialise s=0 and add all the three numbers and store it in s
- Display the sum
Similar questions