Esimene Õpigrupp
This commit is contained in:
6
.classpath
Normal file
6
.classpath
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
||||||
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
bin/
|
||||||
17
.project
Normal file
17
.project
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>opigrupp</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
11
.settings/org.eclipse.jdt.core.prefs
Normal file
11
.settings/org.eclipse.jdt.core.prefs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.source=1.8
|
||||||
22
src/opigrupp1/Meetotid.java
Normal file
22
src/opigrupp1/Meetotid.java
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package opigrupp1;
|
||||||
|
|
||||||
|
public class Meetotid /* see on nimi */ {
|
||||||
|
|
||||||
|
private static int tereTere() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int veelTere(int saadetis){
|
||||||
|
saadetis = saadetis + 1;
|
||||||
|
return saadetis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
int mingimuutuja = tereTere();
|
||||||
|
int veelMuutuja = veelTere(5);
|
||||||
|
System.out.println(mingimuutuja);
|
||||||
|
System.out.println(veelMuutuja);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
101
src/opigrupp1/Muutujad.java
Normal file
101
src/opigrupp1/Muutujad.java
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
package opigrupp1;
|
||||||
|
|
||||||
|
import java.util.InputMismatchException;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class Muutujad {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
int number;
|
||||||
|
double komakohaga = 5.6;
|
||||||
|
boolean tingimus = false;
|
||||||
|
char minumuutuja = 'a';
|
||||||
|
|
||||||
|
String minuTekst = "Tere maailm!";
|
||||||
|
|
||||||
|
int a = 5;
|
||||||
|
double b = 2;
|
||||||
|
double c = a / b;
|
||||||
|
//System.out.printf("%d", c);
|
||||||
|
//System.out.printf("%.3f", c);
|
||||||
|
//System.out.printf(" %s rebane", minuTekst);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int[] veelmassiive;
|
||||||
|
int[] massiiv = {1, 2, 3, 99};
|
||||||
|
//int[] j2rgminemassiiv = new int[] {1,3,4};
|
||||||
|
int[][] kaksDMassiiv = {
|
||||||
|
{1, 2},
|
||||||
|
{3, 4},
|
||||||
|
{5, 6}
|
||||||
|
};
|
||||||
|
|
||||||
|
//System.out.println(kaksDMassiiv[0][1]); //prints 2
|
||||||
|
|
||||||
|
String[] minuLaheTekst = new String[5];
|
||||||
|
|
||||||
|
// lisame 1. sahti teksti
|
||||||
|
minuLaheTekst[0] = "Kass";
|
||||||
|
|
||||||
|
// lisame 2. sahti teksti
|
||||||
|
minuLaheTekst[1] = "Tere Koer!";
|
||||||
|
|
||||||
|
// see ei toimi sest 42 ei ole String tüüp!
|
||||||
|
//minuLaheTekst[2] = 42;
|
||||||
|
|
||||||
|
|
||||||
|
massiiv[0] = 42; // esimese sahtli väärtus on 42
|
||||||
|
massiiv[3] = 5;
|
||||||
|
massiiv[2] = 5*5; //kolmanda sahtli väärtus on 5 korda 5
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//System.out.println(massiiv[0] + " " + massiiv[3]);
|
||||||
|
|
||||||
|
int[] kahegajaguvad = new int[100];
|
||||||
|
|
||||||
|
for(int i = 0; i < 100; i++){
|
||||||
|
kahegajaguvad[i] = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
String minuTest = "salakala";
|
||||||
|
|
||||||
|
//System.out.println(minuTest.length());
|
||||||
|
|
||||||
|
Scanner input = new Scanner(System.in);
|
||||||
|
//System.out.print("input: ");
|
||||||
|
//int s = input.nextInt();
|
||||||
|
int s = getInt();
|
||||||
|
System.out.println(s);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getInt() {
|
||||||
|
int asdf;
|
||||||
|
for (asdf = -1; asdf != 2;) {
|
||||||
|
try {
|
||||||
|
Scanner input = new Scanner(System.in);
|
||||||
|
System.out.print("input: ");
|
||||||
|
asdf = input.nextInt();
|
||||||
|
//break; // exit while
|
||||||
|
} catch(InputMismatchException e) {
|
||||||
|
//System.out.printf("u fuked up mate: %s", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return asdf;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
61
src/opigrupp1/kaksDMasiiv.java
Normal file
61
src/opigrupp1/kaksDMasiiv.java
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
package opigrupp1;
|
||||||
|
|
||||||
|
public class kaksDMasiiv {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
int[][] kaksDMassiiv = {{1, 2},{3, 4},{5, 6}};
|
||||||
|
int[][] kaksDMassiiv2 = new int[3][2];
|
||||||
|
|
||||||
|
//System.out.println(kaksDMassiiv[0][1]); //prints 2
|
||||||
|
//System.out.println(kaksDMassiiv[2][0]); //prints 5
|
||||||
|
|
||||||
|
|
||||||
|
// = new int[7];
|
||||||
|
int[] arvud = new int[]{1,3,0,5,0,6,0};
|
||||||
|
|
||||||
|
|
||||||
|
int arv = 0;
|
||||||
|
//need kolm rida teevad sama asja
|
||||||
|
arv = arv + 1;
|
||||||
|
arv += 1;
|
||||||
|
arv++;
|
||||||
|
|
||||||
|
arv = arv - 1;
|
||||||
|
arv -= 1;
|
||||||
|
arv--;
|
||||||
|
|
||||||
|
arv = arv * 1;
|
||||||
|
arv *= 1;
|
||||||
|
// kolmandata varianti pole
|
||||||
|
|
||||||
|
arv = arv / 1;
|
||||||
|
arv /= 1;
|
||||||
|
// kolmandata varianti pole ka siin
|
||||||
|
|
||||||
|
// minimaalne for tsükkel
|
||||||
|
for (int i = 1; i < 10; i = i + 4) {
|
||||||
|
System.out.println(i);
|
||||||
|
}
|
||||||
|
//System.out.println(i); // see rida feilib sest i ei eksisteeri enam
|
||||||
|
|
||||||
|
int mingi = 3;
|
||||||
|
switch (mingi) {
|
||||||
|
case 1:
|
||||||
|
System.out.println("kirjutati 1");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
// leian mitu nulli on massiivis
|
||||||
|
int nullideArv = 0;
|
||||||
|
for(int i = 1; i < arvud.length; i = i + 2){
|
||||||
|
if(arvud[i] == 0){
|
||||||
|
//nullideArv = nullideArv + 1;
|
||||||
|
nullideArv++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println("Nullide arv massiivis on " + nullideArv);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user