Question: Write a java program that prompts the user to input five decimal numbers. The program should then add the five decimal numbers, convert the sum
Write a java program that prompts the user to input five decimal numbers. The program should then add the five decimal numbers, convert the sum to the nearest integer, and print the result.
Please either write a new one or fix my attempt. Thanks

* import java.util.*; public class Sum { static Scanner console = new Scanner(System.in); Run Debug public static void main(String[] args) { double a1, a2, a3, a4, a5; System.out.print("Enter 5 numbers in decimal form: "); a1 = a2 a4 = a5 console.nextDouble(); console.nextDouble(); console.nextDouble(); console.nextDouble(); console.nextDouble(); System.out.println("The sum is " + (a1+a2+a3+04+a5)); System.out.println("The INT sum is " + Math.round(a1+a2+a3+a4+a5)); + }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
