Exercise #1: Cumulative sum: Write a Java program that prompts the user to enter an integer number (n) that indicates the number of elements of an array (the maximum value for n is 100). Then the user enters n double numbers. The program creates another array of cumulative sums of the first array and outputs it. One decimal place should be used to output the cumulative array. Sample inputs/outputs: Enter the array size: 4 Enter the array elements: 5.0 6.5 7.3 10.2 Cumulative Array: 5.0 11.5 18.8 29.0 Enter the array size: 101 The maximum size is 100! Enter the array size: 5 Enter the array elements: 2.34 5.61 4.67 0.897 Cumulative Array: 2.3 8.0 12.6 19.6 20.4

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter6: Arrays
Section: Chapter Questions
Problem 6RQ
icon
Related questions
Question
Exercise #1: Cumulative sum:
Write a Java program that prompts the user to enter an integer number (n) that indicates the number
of elements of an array (the maximum value for n is 100). Then the user enters n double numbers.
The program creates another array of cumulative sums of the first array and outputs it. One decimal
place should be used to output the cumulative array.
Sample inputs/outputs:
Enter the array size: 4
Enter the array elements: 5.0 6.5 7.3 10.2
Cumulative Array: 5.0 11.5 18.8 29.0
Enter the array size: 101
The maximum size is 100!
Enter the array size: 5
Enter the array elements: 2.34 5.61 4.67 0.897
Cumulative Array: 2.3 8.0 12.6 19.6 20.4
Transcribed Image Text:Exercise #1: Cumulative sum: Write a Java program that prompts the user to enter an integer number (n) that indicates the number of elements of an array (the maximum value for n is 100). Then the user enters n double numbers. The program creates another array of cumulative sums of the first array and outputs it. One decimal place should be used to output the cumulative array. Sample inputs/outputs: Enter the array size: 4 Enter the array elements: 5.0 6.5 7.3 10.2 Cumulative Array: 5.0 11.5 18.8 29.0 Enter the array size: 101 The maximum size is 100! Enter the array size: 5 Enter the array elements: 2.34 5.61 4.67 0.897 Cumulative Array: 2.3 8.0 12.6 19.6 20.4
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning