Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

* 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago