[SOLVED] SOLVED: Sum and Product--program logic

10.99 $

Programming resource
Digital learning resource
Category:
Practical programming resource
Suitable for guided study and reference
Tutor guidance available when needed

Description

5/5 - (2 votes)

Create the logic for a program that continuously prompts a user for a numeric value until the user enters 0. 2. The application passes the value in turn to a method that computes the sum of all the whole numbers from 1 up to and including the entered number. Example if the number entered is 4 the displayed value would be 10 (1+2+3+4). 3. Also to a method that computes the product of all the whole numbers up to and including the entered number. Example if the number entered is 4 the displayed value would be 24 (1*2*3*4). ************************************************************************************************************************** / SumAndProduct.java – This program computes sums and products. // Input: Interactive. // Output: Computed sum and product. import javax.swing.*; public class SumAndProduct { public static void main(String args[]) { int number; String numberString; numberString = JOptionPane.showInputDialog(“Enter a positive integer or 0 to quit: “); number = Integer.parseInt(numberString); while(number != 0) { // call sums() method here // call products() method here

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.