mirror of https://github.com/01-edu/public.git
Compare commits
5 Commits
0610a2cb0f
...
8a952b797c
Author | SHA1 | Date |
---|---|---|
zanninso | 8a952b797c | 4 weeks ago |
zanninso | 8e53a43c56 | 4 weeks ago |
zanninso | 50c790876e | 4 weeks ago |
zanninso | ad35c24f25 | 4 weeks ago |
zanninso | 421897ecff | 4 weeks ago |
5 changed files with 192 additions and 0 deletions
@ -0,0 +1,36 @@
|
||||
## AverageCalc |
||||
|
||||
### Instructions |
||||
|
||||
Write a function named `average` in a file named `AverageCalc` java. This function takes three parameters: start, end, and step. It returns the average of the numbers between start and end with each number being greater than the previous one by the step given. |
||||
|
||||
### Expected Functions |
||||
|
||||
```java |
||||
public class AverageCalc { |
||||
public static int average(int start, int end, int step) { |
||||
// your code here |
||||
} |
||||
} |
||||
``` |
||||
|
||||
### Usage |
||||
|
||||
Here is a possible `ExerciseRunner.java` to test your function : |
||||
|
||||
```java |
||||
public class ExerciseRunner { |
||||
public static void main(String[] args) { |
||||
System.out.println(AverageCalc.average(1,5,1)); |
||||
} |
||||
} |
||||
``` |
||||
|
||||
and its output : |
||||
|
||||
```shell |
||||
$ javac *.java -d build |
||||
$ java -cp build ExerciseRunner |
||||
3 |
||||
$ |
||||
``` |
@ -0,0 +1,36 @@
|
||||
## Digitlen |
||||
|
||||
### Instructions |
||||
|
||||
In a file named `Digitlen.java` write a function `digitlen` that returns the count of digits in the number passed as a parameter. |
||||
|
||||
### Expected Functions |
||||
|
||||
```java |
||||
public class Digitlen { |
||||
public static int digitlen(long number) { |
||||
// your code here |
||||
} |
||||
} |
||||
``` |
||||
|
||||
### Usage |
||||
|
||||
Here is a possible `ExerciseRunner.java` to test your function : |
||||
|
||||
```java |
||||
public class ExerciseRunner { |
||||
public static void main(String[] args) { |
||||
System.out.println(Digitlen.digitlen(9989898878)); |
||||
} |
||||
} |
||||
``` |
||||
|
||||
and its output : |
||||
|
||||
```shell |
||||
$ javac *.java -d build |
||||
$ java -cp build ExerciseRunner |
||||
10 |
||||
$ |
||||
``` |
@ -0,0 +1,45 @@
|
||||
## MultiplicationTable |
||||
|
||||
### Instructions |
||||
|
||||
In a file named `MultiplicationTable.java` write a function `generate` which takes a number as a parameter, and prints the multiplication table for this number. |
||||
|
||||
### Expected Functions |
||||
|
||||
```java |
||||
public class MultiplicationTable { |
||||
public static void generate(int num) { |
||||
// your code here |
||||
} |
||||
} |
||||
``` |
||||
|
||||
### Usage |
||||
|
||||
Here is a possible `ExerciseRunner.java` to test your function : |
||||
|
||||
```java |
||||
public class ExerciseRunner { |
||||
public static void main(String[] args) { |
||||
MultiplicationTable.generate(5); |
||||
} |
||||
} |
||||
``` |
||||
|
||||
and its output : |
||||
|
||||
```shell |
||||
$ javac *.java -d build |
||||
$ java -cp build ExerciseRunner |
||||
5 x 1 = 5 |
||||
5 x 2 = 10 |
||||
5 x 3 = 15 |
||||
5 x 4 = 20 |
||||
5 x 5 = 25 |
||||
5 x 6 = 30 |
||||
5 x 7 = 35 |
||||
5 x 8 = 40 |
||||
5 x 9 = 45 |
||||
5 x 10 = 50 |
||||
$ |
||||
``` |
@ -0,0 +1,39 @@
|
||||
## SortArray |
||||
|
||||
### Instructions |
||||
|
||||
In a file named `SortArray.java` write a function `sort` that returns the given array, specified in the parameters, sorted in ascending order. |
||||
|
||||
### Expected Functions |
||||
|
||||
```java |
||||
public class SortArray { |
||||
public static Integer[] sort(Integer[] args) { |
||||
// your code here |
||||
} |
||||
} |
||||
``` |
||||
|
||||
### Usage |
||||
|
||||
Here is a possible `ExerciseRunner.java` to test your function : |
||||
|
||||
```java |
||||
import java.io.*; |
||||
import java.util.Arrays; |
||||
|
||||
public class ExerciseRunner { |
||||
public static void main(String[] args) throws IOException { |
||||
System.out.println(Arrays.toString(SortArray.sort(new Integer[]{4, 2, 1, 3}))); |
||||
} |
||||
} |
||||
``` |
||||
|
||||
and its output : |
||||
|
||||
```shell |
||||
$ javac *.java -d build |
||||
$ java -cp build ExerciseRunner |
||||
[1, 2, 3, 4] |
||||
$ |
||||
``` |
@ -0,0 +1,36 @@
|
||||
## Strlen |
||||
|
||||
### Instructions |
||||
|
||||
In a file named `Strlen.java` write a function `strlen` that returns the length of the string passed as a parameter. |
||||
|
||||
### Expected Functions |
||||
|
||||
```java |
||||
public class Strlen { |
||||
public static int strlen(String s) { |
||||
// your code here |
||||
} |
||||
} |
||||
``` |
||||
|
||||
### Usage |
||||
|
||||
Here is a possible `ExerciseRunner.java` to test your function : |
||||
|
||||
```java |
||||
public class ExerciseRunner { |
||||
public static void main(String[] args) { |
||||
System.out.println(Strlen.strlen("Hello World !")); |
||||
} |
||||
} |
||||
``` |
||||
|
||||
and its output : |
||||
|
||||
```shell |
||||
$ javac *.java -d build |
||||
$ java -cp build ExerciseRunner |
||||
13 |
||||
$ |
||||
``` |
Loading…
Reference in new issue