Create a JAVA program with a while loop that asks the user to enter a number and ends when a 0 is entered. Then find the product of the numbers entered.
import java.util.Scanner; public class ProductOfNumbers { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int product = 1, n; System.out.print("Enter number: "); n = scan.nextInt(); while(n!=0){ product = product * n; System.out.print("Enter number: "); n = scan.nextInt(); } System.out.println("Product: "+product); } }
Get Answers For Free
Most questions answered within 1 hours.