0% found this document useful (0 votes)
94 views3 pages

Progr 5

The document describes two programming tasks: 1) Write a program to count the frequency of lowercase letters in a string and report the results. 2) Write a Characters class with static methods to print characters on a 4x4 or 8x8 grid, including variables to represent blank/filled squares and an alphabet table encoded as 16-bit binary values.

Uploaded by

Marta Tolevska
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views3 pages

Progr 5

The document describes two programming tasks: 1) Write a program to count the frequency of lowercase letters in a string and report the results. 2) Write a Characters class with static methods to print characters on a 4x4 or 8x8 grid, including variables to represent blank/filled squares and an alphabet table encoded as 16-bit binary values.

Uploaded by

Marta Tolevska
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

1.

Write a program that composes a string from the given arguments and counts how many times a
single lowercase letter of the English alphabet appears in that string. If the string does not contain
any lowercase letters, have the program report it with an appropriate message.

Example: on call

java DN05 abc abe axc

let the program display:

The letters a (3), b (2), c (2), e (1), x (1) appear in the string 'abc abe axc'.

2. Write the Characters class and in it the static methods for printing characters defined on a 4 x 4
and 8 x 8 grid.

In the Characters class, declare the following variables and tables:

private static final char blackDot = '\ u2B1B'; // black square

private static final char whiteDot = '\ u2B1C'; // blank (white) square

private static final char [] alphabet = {

'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M ',

'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z ',

'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ''};

private static final short [] kodeZnakov16bit = {

(short) 0b1111100111111001, // A

(short) 0b1100101011011010, // B

(short) 0b1111100010001111, // C

(short) 0b1110100110011110, // D

(short) 0b1111111010001111, // E
(short) 0b1111100011101000, // F

(short) 0b1111100010111111, // G

(short) 0b1001100111111001, // H

(short) 0b1111010001001111, // I

(short) 0b1111000110011111, //

(short) 0b1011110010101001, // K

(short) 0b1000100010001111, // L

(short) 0b1111101110011001, // M

(short) 0b1101101110011001, // N

(short) 0b1111100110011111, // O

(short) 0b0, // TODO: add character P

(short) 0b1111100110111111, // Q

(short) 0b1111100111111010, // R

(short) 0b1111100011110111, // S

(short) 0b1111010001000100, // T

(short) 0b1001100110011111, // U

(short) 0b1001100110010110, // V

(short) 0b1001100110111111, // W

(short) 0b1001011001101001, // X

(short) 0b1001100111110100, // Y

(short) 0b1111001001001111, // Z

(short) 0b0110100110010110, // 0

(short) 0b0110001000101111, // 1

(short) 0b0, // TODO: add character 2

(short) 0b1111011100011111, // 3

(short) 0b1000100111110001, // 4

(short) 0b1111100011110111, // 5

(short) 0b1000111110011111, // 6

(short) 0b1111000100010001, // 7

(short) 0b1110101111010111, // 8

(short) 0b1111100111110001, // 9
0 // space

};

where the 16bit Character code table contains characters of the alphabet represented by 16 bits.
The record 0b1111100111111001 is an example of a binary record of the value of a variable, where
0b predicts that it is a binary record, followed by bits from the one with the highest weight to the
one with the lowest (0b [bit-15] [bit-14] ... [bit- 2] [bit-1] [bit-0]). The diagram below shows the
arrangement of bits in the character, where 0 is the lowest bit and 15 is the highest bit:

15 14 13 12
11 10 9 8
7 6 5 4
3 2 1 0

You might also like