Extra Sheet Java After Work Sheet
Extra Sheet Java After Work Sheet
Test Data
Input the number of minutes: 3456789
Expected Output :
3456789 minutes is approximately 6 years and 210 days
Selection Statements
Write a Java program that takes the user to provide a single character from the alphabet. Print Vowel or
Consonant, depending on the user input. If the user input is not a letter (between a and z or A and Z), or is a
string of length > 1, print an error message.
Test Data
Input an alphabet: p
Expected Output :
Input letter is Consonant
LOOP
Write a Java program to print the value of the Fibonacci sequence. The Fibonacci sequence for entered
number from the user is defined by the following rule. The first 2 values in the sequence are 1, 1. Every
subsequent value is the sum of the 2 values preceding it, the variable t from user represents the number of
items within Fibonacci sequence.
Nested Loop
Write a program in Java to print the Floyd's Triangle.
Test Data
Input number of rows : 5
Expected Output :
01
101
0101
10101
Methods
Write a Java method to compute the sum of the digits in an integer.
Test Data:
Input an integer: 25
Expected Output:
The sum is 7