# Java â€“ Practice Quiz by jcc96858

VIEWS: 0 PAGES: 2

• pg 1
```									                                          Java Quiz

For each of the following sections, insert the command that will require the user to press
enter data in order to continue:

Write a single Java program that will: (2 marks each)

a. print the multiples of five from 100 to 200
b. ask the user for a number and tell the user whether the number is less than or
greater than 100.
c. ask the user for a 7 letter word. If a 7 letter word
is entered then the word ACCEPTED is                   quote = "All good things must end"
displayed. Otherwise the word REJECTED is              print
displayed. You will need to read this example in       print len(quote)
order to efficiently deal with this problem
d. Ask the user for two numbers and print the
following:
o The total
o Whether the total is greater or less than 10
o The numbers in order from smallest to largest
o How many of the numbers are less than 10
o How many of the numbers contain a 7 as one of their digits

e. Ask the user for a number and print all the factors of the number
f. Print a list of all the numbers between 10 and 50 along with how many factors
they have: (see chart below)
g. Use a loop to print all the prime numbers between 1 and 1000
h. There are twenty one number less than 100 where the sum of the factors is greater
than the number itself. For example …30 is one of them since the factors of 30
are 1, 2, 3, 5, 6, 15, 1 + 2 + 3 + 5 + 6 + 15 is greater than 30. Find the other 20
numbers that have this property.
i. Use two loops to print the following pattern
1
1       2
1       2        3
1       2        3        4
1       2        3        4      5
1       2        3        4      5      6

j. A fibonacci sequence begins with the numbers 1 and 2. Each successive term is
the sum of the previous two terms. Print the first 20 numbers of the sequence:

1       2      3       5       8       13      21     34     ………

Number                                  Number of factors
11                                           2
12                                           6
13                                           2
14     4
15     4
16     5
17     2
18     6
19     2
…..   …….

```
To top