Õpigrupp 2 kood

This commit is contained in:
2015-10-22 15:59:01 +03:00
parent dd0352bf14
commit 15bb5d3f46
9 changed files with 289 additions and 9 deletions

View File

@@ -6,7 +6,13 @@ import java.util.Scanner;
public class Muutujad {
public static void main(String[] args) {
int number;
int number = 42; // see ja alumine on samad
int number2;
number2 = 666;
// -0.5e2
double komakohaga = 5.6;
boolean tingimus = false;
char minumuutuja = 'a';
@@ -16,17 +22,26 @@ public class Muutujad {
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);
//System.out.printf("%d", c); // %d prindib int muutujaid
System.out.printf("%3.3f", c); // %f on komakohaga (float, double)
System.out.print("tere :");
System.out.print(a); //
System.out.println(" oli number");
System.out.println("tere :" + a + " oli number");
System.out.printf("tere :%d oli number%n", a);
System.out.printf("int: %d, double: %f, String: %s", a,c,minuTekst);
//teksti printime kasutades printf
String tekstiMuutuja = "see on tekst";
System.out.printf("\n minu tekst: %s ", tekstiMuutuja);
//täisarvu printimine kasutades printf
int miskiNumber = 3;
System.out.printf("\n see on number: %d", miskiNumber);
// komakohaga arvu printimine kasutades printf
double komaKohaga = 3.56565;
System.out.printf("\n see on komakohaga arv: %f ", komaKohaga);