SHARE
TWEET

Untitled

a guest Apr 25th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package z_kolok;
  2.  
  3. import java.util.Scanner;
  4.  
  5. /*
  6. * 5 podatka unutar 1 minute
  7. * jednaki vr
  8. */
  9. public class z_kolokkk {
  10. static Scanner reader = new Scanner(System.in);
  11. private static int min;
  12.  
  13. private static class unosTemperatura implements Runnable{
  14. int temperature[];
  15.  
  16. public unosTemperatura(int[] temperature) {
  17. this.temperature = temperature;
  18. }
  19.  
  20. @Override
  21. public void run() {
  22. int tempVar;
  23. try {
  24. int i=0;
  25. while(i<5) {
  26. System.out.println("Unesite vrijednost: ");
  27. tempVar = reader.nextInt();
  28. if(tempVar>0) {
  29. temperature[i] = tempVar;
  30. int a = i+1;
  31. System.out.println("Unešen je " + a + ". unos" );
  32. i++;
  33. if(tempVar>90) System.out.println("Provjeri da li je danas koncert");
  34. else if(tempVar>65) System.out.println("Provjeri koliko je sati");
  35. }
  36. else System.out.println("Uneseni broj je manji od 0!\n Ponovite.");
  37.  
  38. Thread.sleep(12500);
  39. }
  40. }catch(InterruptedException e) {
  41. System.out.println("Nije sve uneseno!");
  42. }
  43.  
  44.  
  45.  
  46. }
  47.  
  48. }
  49. /*
  50. * glavna dretva ceka da druga zavrsi i
  51. * ispise prosjecnu i min/max razinu
  52. *
  53. * Ako iznad 65 dBA program salje por "Provjeri koliko je sati"
  54. * Ako iznad 90 dBA program salje por "Provjeri da li je danas koncert"
  55. */
  56.  
  57. public static void main(String args[]) throws InterruptedException{
  58. int temperature[] = {0,0,0,0,0};
  59. Thread DretvaTemperature = new Thread(new unosTemperatura(temperature));
  60. DretvaTemperature.start();
  61.  
  62. while(DretvaTemperature.isAlive()) {
  63. DretvaTemperature.join(1);
  64. }
  65.  
  66.  
  67.  
  68. int min=temperature[0];
  69. int max=temperature[0];
  70. for(int index=0;index<5;index++) {
  71. //System.out.println(temperature[index]);
  72. if(min>temperature[index]) min=temperature[index];
  73. else if(max<temperature[index]) max=temperature[index];
  74.  
  75. }
  76. System.out.println("\nMinimum je: "+min+"\nMaksimum je: "+max);
  77. }
  78.  
  79. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top