Wednesday, February 28, 2018

Chapter 5 Homework Conditions and Test Results

1. Ask for 2 numbers
2. Calculate how many multiples there are between the 2 numbers entered
 A. How many multiples of 3 are there
 B. How many multiples of 5 are there
3. Output the results
==========================================
Solution
Test 1
Enter two integers: 1 3
Multiples of 3 between 1 and 3: 1
Multiples of 5 between 1 and 3: 0
Test 2
Enter two integers: 100 5000
Multiples of 3 between 100 and 5000: 1633
Multiples of 5 between 100 and 5000: 981
Test 3
Enter two integers: 50 2
Multiples of 3 between 2 and 50: 16
Multiples of 5 between 2 and 50: 10
Test 4
Enter two integers: 451 21345
Multiples of 3 between 451 and 21345: 6965
Multiples of 5 between 451 and 21345: 4179
Test 5
Enter two integers: 3 3
Multiples of 3 between 3 and 3: 1
Multiples of 5 between 3 and 3: 0
Test 6
Enter two integers: 5 5
Multiples of 3 between 5 and 5: 0
Multiples of 5 between 5 and 5: 1

No comments: