Code example for Scanner

Methods: hasNextIntnextInt

				.println("This program calculates the area and the circumference of a circle with a given radius.");
		System.out.println("Please give the radius of the circle in cm..");
		input = new Scanner(;
		if (input.hasNextInt()) {
			radius = input.nextInt();
			area = Math.PI * Math.pow(radius, 2);
			circumf = 2 * Math.PI * radius;
			DecimalFormat format = new DecimalFormat("#.##");
			System.out.println("The radius of the circle is "
					+ format.format(radius) + " cm.");
			System.out.println("The area of the circle is "
					+ format.format(area) + " square cm.");
			System.out.println("The circumference of the circle is "
Stop searching for code, let great code find you!  Add Codota to your java IDE