Challenges
Chapter 04 - Storing and processing data - Challenges
Data Types
In the most left column is a piece of data that is stored inside of the computers memory. What would be a possible data type for each piece of information? In some cases multiple data types would be valid.
Data
int
double
boolean
char
String
128
[]
[]
[]
[]
[]
-12
[]
[]
[]
[]
[]
a
[]
[]
[]
[]
[]
Hello World
[]
[]
[]
[]
[]
108.6
[]
[]
[]
[]
[]
true
[]
[]
[]
[]
[]
Spoorwegstraat 12, 8200 Brugge
[]
[]
[]
[]
[]
A
[]
[]
[]
[]
[]
0471 11 18 23
[]
[]
[]
[]
[]
3.14
[]
[]
[]
[]
[]
x
[]
[]
[]
[]
[]
ZZ Top
[]
[]
[]
[]
[]
false
[]
[]
[]
[]
[]
-778.81323
[]
[]
[]
[]
[]
Basic Division
Determine the result of 2 divided by 3. Next try out 2.0 divided by 3.
Floating Point Division
Take the code below and execute it:
How can you change only the last line to get a result of 2.5
?
Remainder
What is the remainder of 8759 divided by 33?
Calculating VAT
When buying a product in the store you always need to pay VAT (taxes). Take for example a pair of shoes that costs 100eur net, you actually pay 121eur.
Write a program that calculates how much the total bill would be if the net amount is 250eur.
Rectangle Area
Determine the area of a rectangle with a side of 2.3cm and a side of 8.2cm. Make your program outputs a decent result to the user.
String Concatenation
Take the code below and change the variable fullText
to contain all partial strings before it.
Print out the variable fullText
so the whole message is shown to the user.
Circle Properties
Write a Java program to determine the area and circumference of a circle. They can be calculated using the formulas below:
Make sure all the variables are of type double
.
Print all the parameters to the terminal (radius, diameter, area and circumference) so the user had a nice overview. For example:
You can create a variable to hold an approximation to the value of pi. However, Java can supply a more accurate version of PI. Can you find on the Internet how to access/use this value?
Concatenation and Addition
Explain the difference in output between the following two lines of code:
Last updated