Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.ejb.*;
- import javax.naming.*;
- /**
- * Aplikacja do zadania 05
- * @author Krzysztof "Szalix" Szala
- */
- public class Client {
- public static void main(String[] args) throws Exception {
- //Wyszukiwanie implementacji interfejsu
- Context initialContext = new InitialContext();
- HMonitor monitor = (HMonitor) initialContext.lookup("java:global/ejb-project/HMonitorImpl");
- //zmienne pomocnicze do algorytmu
- double result = 0;
- double currentValue = 0;
- double squareSum = 0;
- double sumToMean = 0;
- double mean =0;
- int numberOfElements = 0;
- //sprawdzenie czy uda sie zarejestrowac
- if(hMonitor.register(5, "94067") == true){
- //wczytanie kazdego elementu z iteratora do listy
- //policzenie wartosci pomocniczych
- while(monitor.hasNext()){
- currentValue = monitor.next();
- sumToMean += currentValue;
- squareSum += currentValue*currentValue;
- numberOfElements++;
- }
- //srednia
- mean = sumToMean / numberOfElements;
- //wynik srednia kwadratow przez ilosc elementow i srednia kwadrat
- result = squareSum/numberOfElements - mean*mean;
- System.out.print(result);
- }
- else{
- System.out.println("Error while registration!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement