Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class trougao
- {
- public static void main(String args[])
- {
- double a,b,c;
- a = Double.parseDouble(args[0]);
- b = Double.parseDouble(args[1]);
- if(a>0 && b>0)
- {
- c = Math.sqrt(Math.pow(a, 2)+Math.pow(b, 2));
- System.out.println("a = "+a+ "\nb = "+b+"\nc = "+c);
- }
- else
- {
- System.out.println("negativne vrijednosti");
- }
- }
- }
- import java.util.*;
- public class zadatak2
- {
- public static void main(String[] args)
- {
- int a, b, c, min;
- boolean provera = false;
- Scanner scan = new Scanner(System.in); // upis sa tastature
- do{
- System.out.print("a = ");
- a = scan.nextInt();
- System.out.print("b = ");
- b = scan.nextInt();
- System.out.print("c = ");
- c = scan.nextInt();
- if(a >= 0 && b >= 0 && c >= 0)
- {
- provera = false;
- min = a;
- if (b<a) min = b;
- if (c<a) min = c;
- System.out.println("min("+a+", "+b+", "+c+") = "+min);
- }else
- {
- provera = true;
- System.out.println("Neispravne vrijednosti");
- }
- }while(provera);
- }
- }
- import java.util.Scanner;
- public class zadatak3
- {
- public static void main(String[] args)
- {
- int niz[]= new int[10]; //pravi niz od 10 integera
- //int niz2[] = [1, 2, 3, 4, 5, 6, 7];
- Scanner scan = new Scanner(System.in);
- for (int i = 0; i<10; i++)
- {
- System.out.print(i+1+". broj = ");
- niz[i]= scan.nextInt();
- }
- int min=niz[0];
- for (int i = 0; i< 10; i++)
- {
- if (niz[i]< min ) min = niz[i];
- }
- System.out.print("Najmanji broj je "+ min);
- }
- }
- import java.util.Scanner;
- public class zadatak3
- {
- public static void main(String[] args)
- {
- int niz[]= new int[10]; //pravi niz od 10 integera
- //int niz2[] = [1, 2, 3, 4, 5, 6, 7];
- Scanner scan = new Scanner(System.in);
- int min=0;
- for (int i = 0; i<10; i++)
- {
- System.out.print(i+1+". broj = ");
- niz[i]= scan.nextInt();
- if(i == 0)
- {
- min = niz[i];
- }else{
- if (niz[i] < min ) min = niz[i];
- }
- }
- System.out.print("Najmanji broj je "+ min);
- }
- }
- import java.util.Scanner;
- public class zadatak4
- {
- public static void main(String[] args)
- {
- int a,b,c,pom;
- Scanner scan = new Scanner(System.in);
- System.out.print("a = ");
- a = scan.nextInt();
- System.out.print("b = ");
- b = scan.nextInt();
- System.out.print("c = ");
- c = scan.nextInt();
- if(a > b) // poredimo 1. i 2.
- {
- pom = a; a = b; b = pom;
- }
- if (a>c) // poredimo 1. i 3.
- {
- pom = a; a = c; c = pom;
- }
- if (b>c) // poredimo 2. i 3.
- {
- pom = b; b = c; c = pom;
- }
- System.out.println("Uredjeno: "+a+", "+b+", "+c);
- }
- }
- import java.util.*;
- public class Zadatak5
- {
- public static void main(String[] args)
- {
- ArrayList<Integer> lista = new ArrayList();
- Scanner scan = new Scanner(System.in);
- int temp = 0;
- do{
- System.out.print(lista.size()+1+". broj =");
- temp = scan.nextInt();
- if(temp != 0 )
- lista.add(temp);
- else
- System.out.println("-- kraj");
- }while(temp != 0 );
- System.out.println("1. nacin ispisa el liste");
- for(int i = 0; i < lista.size(); i++)
- {
- System.out.println(lista.get(i));
- }
- Comparator com = Collections.reverseOrder();
- Collections.sort(lista, com);
- System.out.println("2. nacin ispisa el liste");
- for(int t : lista)
- {
- System.out.println(t);
- }
- System.out.println("MAX = "+Collections.max(lista)+" MIN = "+ Collections.min(lista));
- }
- }
- import java.util.Scanner;
- public class Zadatak6
- {
- public static void main(String[] args)
- {
- double xmin, xmax, dx, x, y;
- Scanner scan = new Scanner(System.in);
- System.out.print("xmin = ");
- xmin = scan.nextDouble();
- System.out.print("xmax = ");
- xmax = scan.nextDouble();
- System.out.print("dx = ");
- dx = scan.nextDouble();
- System.out.println("=====================================");
- System.out.println("x \ty");
- for(x = xmin; x <= xmax; x+=dx)
- {
- y = (x*x-2*x-2)/(x*x+1);
- System.out.println(x+"\t"+y);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement