Getting ready for next Thursday
Here are a few things we have done in class you should be able to do.
And here are some small problems you should be able to do.
Declare an array of characters called
lowerCase
. InitializelowerCase
so that it can contains 26 characters. Store the letters'a'
to'z'
in the elements oflowerCase
.In a single statement, declare and initalize an array of characters called
vowels
that contains the five vowels.Using the documentation of the Java
String
class as a reference, write Java code to do the following actions.In a single statement create a
String
s
that contains the characters, in order, contained in thechar
arrayb
.Determine the number of characters in a
String
s
.Use the
String
static methodvalueOf
and theString
instance methodsubstring
to create aString
which is the first ten digits of π. Use theMath
class to obtain the value of π.
Write a program that reads a series of integers from the terminal. When a negative number is entered, the program should stop reading numbers and print the sum of all the numbers that have been entered.
Write a method that is passed an array of integers and returns the average value of the numbers in the array.
Write a single for loop that prints, in order, all the even integers of an array until the either all the array’s integers have been added or a negative number is found within the array.
Write a small section of code that can, given a
String
s
of the form"2/21/13"
to represent February 21, 2013, prints the month, day, and year encoded ins
.