Spaces:
Running
Running
System.out.println(<some string>);
Browse files
Week 1: Types, condition clauses and loops/2. Nordic countries in alphabetical order
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
public class Example{
|
| 2 |
+
public static void main(String[] args) {
|
| 3 |
+
System.out.println("Welcome to the course!");
|
| 4 |
+
}
|
| 5 |
+
}
|
| 6 |
+
|
| 7 |
+
//Output:
|
| 8 |
+
Welcome to the course!
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
public class Example {
|
| 14 |
+
public static void main(String[] args) {
|
| 15 |
+
System.out.println("Huey");
|
| 16 |
+
System.out.println("Dewey");
|
| 17 |
+
System.out.println("Louie");
|
| 18 |
+
}
|
| 19 |
+
}
|
| 20 |
+
//Output:
|
| 21 |
+
Huey
|
| 22 |
+
Dewey
|
| 23 |
+
Louie
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
// println inserts a linebreak '\n' after each line
|
| 29 |
+
// print does not insert a linebreak '\n' after each line
|
| 30 |
+
public class Example {
|
| 31 |
+
public static void main(String[] args) {
|
| 32 |
+
System.out.print("Welcome ");
|
| 33 |
+
System.out.print("to the course ");
|
| 34 |
+
System.out.println("Introduction to Object-Oriented Programming!");
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
//Output:
|
| 38 |
+
Welcome to the course Introduction to Object-Oriented Programming!
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
'''
|
| 50 |
+
In the task below, the program framework has been completed.
|
| 51 |
+
|
| 52 |
+
Complete the solution by writing lines in the program that print the Nordic countries
|
| 53 |
+
(Finland, Sweden, Norway, Denmark, Iceland) in alphabetical order on the screen.
|
| 54 |
+
Each country is printed on its own line.
|
| 55 |
+
'''
|
| 56 |
+
|
| 57 |
+
public class Test{
|
| 58 |
+
public static void main(String[] args){
|
| 59 |
+
System.out.println("Denmark");
|
| 60 |
+
System.out.println("Finland");
|
| 61 |
+
System.out.println("Iceland");
|
| 62 |
+
System.out.println("Norway");
|
| 63 |
+
System.out.println("Sweden");
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
// output
|
| 68 |
+
Denmark
|
| 69 |
+
Finland
|
| 70 |
+
Iceland
|
| 71 |
+
Norway
|
| 72 |
+
Sweden
|