SOLVED: Sum and Product–program logic

10.99 $ 5.50 $

Category:
Click Category Button to View Your Next Assignment | Homework

You'll get a download link with a: . rar solution files instantly, after Payment

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