"Hello, soldier!"
"Hello, Captain Squirrels, sir!"
"I have great news for you. Here are some exercises to reinforce your skills. Work on them every day, and your competence will grow exponentially. They were specially designed for IntelliJ IDEA."
12
Task
New Java Syntax,
level 12,
lesson 7
Locked
Correct answer: d = 2.941
A spaceship flew to planet of Paleo-Know, and met there creatures that didn't even know integer arithmetic. But this whole story has nothing to do with our task. It's only here as an amazing fact to get your attention. Meanwhile, you need to add one cast operation to the code and get the correct answer.
12
Task
New Java Syntax,
level 12,
lesson 7
Locked
Numbers and strings
The add method should add up the input arguments and return a string like this:
a+b=sum
For example, if you pass (7, 8) to the method, then it should return the string "7+8=15".
But the method is not working properly at present. Your task is to fix it.
12
Task
New Java Syntax,
level 12,
lesson 7
Locked
But that's how I want it
Implement the toCustomString method so that it converts a Number to a String according to a specific type-dependent rule:
- if the argument is a Byte object, then divide it by 2 and convert it to a string, adding the letter "b" at the end;
- if the argument is an Integer object, then divide it by 3
12
Task
New Java Syntax,
level 12,
lesson 7
Locked
Human class constructors
People are different. And each person differs in significant ways. Suppose we have a newborn who has only a name and a mother. Or suppose we have a musician that prizes his band and his ability to perform. Let's write a Human class with 6 fields and come up with 10 different constructors for it. Each constructor should make sense.
12
Task
New Java Syntax,
level 12,
lesson 7
Locked
Use the fewest number of static modifiers
"Fewest statics, maximum result" is the motto for your next task. It will require you to analyze code already written by some good soul, and understand where this kind person forgot to put static modifiers. The code won't compile. But don't stick them everywhere. Try to use them as little as possible.
12
Task
New Java Syntax,
level 12,
lesson 7
Locked
Task about algorithms
We received a new children's assignment from the ordered isomorphs on Planet Linear Chaos. You remember that it was these weirdos who thought up all sorts of sorting techniques and constantly practice them. That's why these tasks are so strange. Check it out: read 30 numbers from the keyboard. Display the 10th and 11th smallest numbers. But, you know, you've got to try it!
"Those previous exercises were for rookies. I've added some more advanced bonus exercises for the old-timers. Just for veterans."
GO TO FULL VERSION