Java Saved Program: kind-palace

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.

	Napisati metodu koja racuna povrsinu pravokutnika zadanog visinom i sirinom (argumenti).

import java.util.*;

import java.lang.*;


import java.util.Scanner;

class Script

	public static void main (String[] args)
		double a = 0, b = 0;
		Scanner scan = new Scanner(;
		System.out.println("Unesite stranice A i B pravokutnika: \n");
		a = scan.nextDouble();
		b = scan.nextDouble();
		System.out.println("Povrsina pravokutnika zadanog stranica A = " + a + " cm i B = " + b + " cm je: " + IzracunajPovrsinu(a, b));

	public static double IzracunajPovrsinu(double a, double b)
		double povrsina = a * b;
		return povrsina;


	 - Inicijalizirati visinu i sirinu
	 - Pomocu Scanner unosimo visinu i sirinu pravokutnika
	 - Napravimo metodu IzracunaPovrsinu koja prima parametre A i B
	 - Unutar metode racunamo povrsinu pravokutnika koju smo prethodno inicijalizirali
	 - Vraca povrsinu koja je tipa double
	 - Saljemo na izlaz povrsinu pravokutnika koju smo pozvali preko metode "IzracunajPovrsinu"


Press the execute button or CTRL + enter to run code.