"I dag er min heldige dag. Jeg fandt på fem nye opgaver til dig. Jeg er fyldt med kreativitet. Held og lykke, min ven. Du får brug for det..."
2
Opgave
Java Syntax, niveau, lektie
Even numbers
A for loop simplifies the counting, simplifies displaying text, and simplifies... the life of a programmer! And it saves a lot of time: just a couple of simple lines of code and you can display every even number from 1 to 100 inclusive. Let's try it, but be sure to put each value on a separate line.
4
Opgave
Java Syntax, niveau, lektie
Drawing a rectangle
Expressive drawing using the modest tools of pseudographics is the same as minimalism in music. At least, some critics on Earth think so. Well, let's heed their words and do some drawing. Let's enter two numbers m and n, and draw a rectangle of eights. The rectangle will be m eights high and n eights wide.
4
Opgave
Java Syntax, niveau, lektie
Triangle of eights
Drawing on the console is called "pseudographics". This technique began at the dawn of the computer age and progressed in parallel with ordinary graphics until the beginning of the Windows era. Then it stagnated and faded away. Maybe you daydream about great pseudographics? Let's start mastering the technique by drawing a "triangle of eights".
2
Opgave
Java Syntax, niveau, lektie
Drawing lines
Everything starts with lines, including the path of an artist. But the path of a programmer begins with the study of loops. At this point, we need to master the for loop. It is convenient, simple, and helps us create. Let's use it to draw horizontal and vertical lines, consisting of ten 8s each.
2
Opgave
Java Syntax, niveau, lektie
Chain letter
Who (or for some people, what) do you see in your sweet dreams? Do you have someone in mind? Make a wish. Write a program that takes a name from the keyboard and displays the phrase " loves me" 10 times. If you do this with a for loop, your wish* will come true (*your wish to become a programmer).