12.07.2015 Views

Java za mlade programere (1) - Tutoriali.org

Java za mlade programere (1) - Tutoriali.org

Java za mlade programere (1) - Tutoriali.org

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Postavite vrednosti <strong>za</strong> neke promenljive (takođe, stavitekomentar <strong>za</strong> ono što radite):// set valuesinchesPerStudent = 5;lengthSandwich1 = 114;lengthSandwich2 = 93;Mi smo postavili navedene vrednosti, vi možete postaviti nekedruge ako želite. Uočite da smo pretpostavili da svaki gostmože da pojede 5 inča od sendviča.Zatim, pomoću običnog deljenja računamo koliko gostijumože da se hrani iz svakog sendviča:// odredite koliko gostiju može da se hrani iz svakog ---//sendvičastudents1 = lengthSandwich1 / inchesPerStudent;students2 = lengthSandwich2 / inchesPerStudent;Uočite da će students1 i students2 biti (kako smo želeli) celi(integer) brojevi. Prikažite rezultate pomoću metoda println:// ispiši rezulatetSystem.out.println("Letting each student eat " +inchesPerStudent + " inches");System.out.println((students1 + students2) + " studentscan eat these two sandwiches!");Uočite kako nadovezivanje stringova funkcioniše. Takođe,uočite da sumiramo broj gostiju pre ispisivanja. Na kraju,

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!