Scientific Programming II

Programming in Java

Unit 1 - Assignment


Total Points: 20

Notes


Problem 1

Your program will take five integer inputs in the range of [1, 1000]. The program has to output the product of the digits of each of these inputs.

Output 1
Input your number
> 5
Product of the digits of 5 = 5
Output 2
Input your number
> 20
Product of the digits of 20 = 0
Output 3
Input your number
> 121
Product of the digits of 121 = 2
Output 4
Input your number
> 525
Product of the digits of 525 = 50
Output 5
Input your number
> 999
Product of the digits of 999 = 729

Problem 2

Your program will take a positive integer, n (> 0) as the input. The input, n represents the number of terms in the series. The program should output the sum (to three decimal places) of the following series:

1 + 1/4 + 1/7 + 1/10 + ...n terms

Output 1
Input N
> 2
1.250
Output 2
Input N
> 5
1.570
Output 3
Input N
> 10
1.806

Problem 3

An applicant for a job will be given a maximum of five typing tests. The applicant will be hired as soon as he or she scores over 50 words per minute on two tests. Write a program that allows a supervisor to enter each typing test score and print “Hire” as soon as the applicant qualifies without asking for further tests. If after five test scores have been entered the applicant still hasn’t qualified, the program should print “Reject”.

Output 1
Enter score: 52
Enter score: 47
Enter score: 54
HIRE!
Output 2
Enter score: 52
Enter score: 47
Enter score: 46
Enter score: 54
HIRE!
Output 3
Enter score: 42
Enter score: 47
Enter score: 46
Enter score: 54
Enter score: 49
REJECT!

Problem 4

Write a program to find the nth (an integer input > 0) Fibonacci number.

Output 1
Input N
> 2
1
Output 2
Input N
> 10
34
Output 3
Input N
> 20
4181