+1-415-670-9189
info@expertsmind.com
Input pairs of natural numbers
Course:- JAVA Programming
Reference No.:- EM13405




Assignment Help
Expertsmind Rated 4.9 / 5 based on 47215 reviews.
Review Site
Assignment Help >> JAVA Programming

The desired functionality is for your programs to input pairs of natural numbers as they're entered by the user, until the user enters a zero as the first in a pair of numbers. The first number in each pair indicates a bin for the second number. For example, the pair of numbers 3 4 means that bin 3 contains the number 4. After the user enters a bin number of 0, your programs then allow the user to enter natural numbers until another 0 is entered; for every natural number i entered, your programs must output the product of all the numbers in bin i (or 0 if there are no numbers in that bin). Throughout all these operations, your programs must be reasonably efficient-there should never be long, noticeable pauses during execution.

Examples of Desired Behavior:

Enter a natural number: 1
Enter a natural number: 2
Enter a natural number: 1
Enter a natural number: 3
Enter a natural number: 1
Enter a natural number: 4
Enter a natural number: 0
Enter a natural number: 1
24
Enter a natural number: 0

(Here bin 1 contains 2, 3, and 4, so the product for bin 1 is 24)

Enter a natural number: 0
Enter a natural number: 2
0
Enter a natural number: 3
0
Enter a natural number: 1
0
Enter a natural number: 0

(Here no bins contain numbers, so 0 is returned for all of their products)

Enter a natural number: 0
Enter a natural number: 0

(Here no numbers are stored and no products are sought)

Enter a natural number: 70000
Enter a natural number: 9
Enter a natural number: 70000
Enter a natural number: 7
Enter a natural number: 100000
Enter a natural number: 1
Enter a natural number: 100000
Enter a natural number: 1
Enter a natural number: 200000
Enter a natural number: 5
Enter a natural number: 200000
Enter a natural number: 0
Enter a natural number: 200000
Enter a natural number: 7
Enter a natural number: 0

Enter a natural number: 70000
63
Enter a natural number: 100000
1
Enter a natural number: 200000
0
Enter a natural number: 1
0
Enter a natural number: 0




Put your comment
 
Minimize


Ask Question & Get Answers from Experts
Browse some more (JAVA Programming) Materials
Recognize one high severity vulnerability for each computer (if there is one). Explain vulnerability and describe control(s) to minimize risk from vulnerability.
Write a java applet (not a java application program) for costco gas station. The applet will first ask you whether you are a costco customer, then the grade of gas you wan
Determine whether the following grammar is an LL grammar by performing the pairwise disjointness test, showing the FIRST sets of each RHS of each nonterminal - Write a Java
This list has some values that occur just once (1, 3, 4, 11, 13, 18), some values that occur twice (9, 16), some values that occur three times (14, 19) and a single value th
Write a program called Product1ToN to compute the product of integers 1 to 10 (i.e., 1×2×3×...×10). Try computing the product from 1 to 11, 1 to 12, 1 to 13 and 1 to 14.
Sorting  given an array with 100,000 entries to sort. Under what circumstances would you use each of the following: insertion sort,mergesort'quicksort
Draw a UML diagram of each of the Shapes, Rectangle and Square classes using the code that has been provided. Complete this using the examples that have been provide in the
Write a program to print all Armstrong numbers between 1 and 500. If sum of cubes of each digit of the number is equal to the number itself, then the number is called an Arm