You are on page 1of 2

Write a Java program that keeps a number from the user and generates an integer between 1 and 7 and

displays
the name of the weekday.

Test Data
Input number: 3
Expected Output :
Wednesday

Write a Java program to find the number of days in a month.

Test Data
Input a month number: 2
Input a year: 2016
Expected Output :
February 2016 has 29 days

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

Exercise 1: Write Java program to allow the user to input his/her age. Then the program will show if the person is
eligible to vote. A person who is eligible to vote must be older than or equal to 18 years old.

Enter your age: 18

You are eligible to vote.

Write a Java program to determine whether an input number is an even number.

Write a method that prints how many of n1, n2, and n3are odd:
public void printNumOdd(int n1, int n2, int n3) {
}

Write a method with a while loop to prints 1 through n in square brackets. For example, if n = 6 print !![1] [2] [3]
[4] [5] [6]

King’s Island needs a program for its admission booths.


When visitors to the park come up to the booth to
purchase their tickets, the worker uses this program to figure out how much to charge them. You will write this
program.
In the first version of the program, there is one ticket price of $30.00.
Senior citizens (age ≥ 65) are given a 50% discount. Write this program as follows. Import your Scanner. Declare
the needed variables (the person’s
age, the base price of a ticket ($30) and the price you will charge). Input the user’s age, compute the price of the
ticket and output the result in a formatted way (that is, using a $). You do not need to use DecimalFormat
for this part of the program but you will as you enhance it so you might want to set this up now. Save, compile and
run your program a few times, asking the user for different ages such as 10, 50, 65, 80 and 0.

You might also like