degree of difficulty: 3
Let three variables be given containing information for a city:
boolean isCapitalCity; int numberOfCitizen; double taxPerCitizen;with the following meaning:
trueif and only if the city is a capital city.
numberOfCitizenis the number of citizens in this city.
taxPerCitizenis the average tax per month a citizen of the city pays.
Give a boolean expression with all three variables that is true if and only if the city is a metropolis.
degreee of difficulty: 1
Give one (!) arithmetic expression that converts the value of a char-variable (16 bit unicode) into the corresponding UTF-8 encoding. The result should be an int-value.
For this exercise you need the tenary operator
boolean-expression ? expression-1 : expression-2,
the bitwise operators &, |, and the shift operators >> and <<
Implement the expression stepwise: first given an expression for converting char-values with 7 bit unicodes into its UTF-8 encoding, then for 11 bit unicodes and finally for 16 bit unicode values.
The resulting expression will be large and hard to read: comment and format it for readability. In practise this programming task should be implemented with addtional variables for intermediate results and if-else-statements (see the solution for examples).
Use the method
Integer.toBinaryString() for debugging and testing your expression.
degreee of difficulty: 3
The electricalv resistance
R of a cylindrical wire with length
l (in meter) and diameter
(in meter) can be computed from the area
A of its diameter (m2) and the
und the resistivity
Ρ of the material (rho, meter times Ohm). The formula:
R = Ρ( l / A )
Compute the electrical resistance of a wire with length 1m and a diameter of 1mm for copper (Ρ = 1,78*10-8) and for silicon (Ρ = 2300)
Ohm's law states the current (I) is proportional to the potential difference (U). As a formula: U = R * I.
What is the resistance of the wire if 25 Ampere current pass through it?