tut02 - write your code here Generate a random lowercase...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
EE3206/EE5805 Java Programming & Application Tutorial 2 1. Generating Random Characters Computer programs process numerical data and characters. You have seen many examples that involve numerical data. It is also important to understand characters and how to process them. Each character has a unique Unicode between 0 and FFFF in hexadecimal (65535 in decimal). To generate a random character is to generate a random integer between 0 and 65535. Now you should write a class to generate random characters. A template is provided for you as shown below. You also have to write a driver to test your class. // RandomCharacter.java: Generate random characters public class RandomCharacter { /** Generate a random character between ch1 and ch2 */ public static char getRandomCharacter(char ch1, char ch2) {
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: // write your code here } /** Generate a random lowercase letter */ public static char getRandomLowerCaseLetter() { // write your code here } /** Generate a random uppercase letter */ public static char getRandomUpperCaseLetter() { // write your code here } /** Generate a random digit character */ public static char getRandomDigitCharacter() { // write your code here } /** Generate a random character */ public static char getRandomCharacter() { // write your code here } } 2. Counting Occurrence of Each Letter Using the RandomCharacter class, write another program to generate 100 lowercase letters randomly and assign to an array of characters. You have to count the occurrence of each letter and display to the screen....
View Full Document

This note was uploaded on 01/11/2011 for the course EE 3206 taught by Professor Cwting during the Spring '07 term at City University of Hong Kong.

Ask a homework question - tutors are online