Практикум по программированию. Основы. Циклы. Расчет масс деталей

From AsIsWiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "Циклы __FORCETOC__ ==Java== <pre> import java.util.Scanner; import java.lang.Mat...")

Revision as of 16:42, 4 April 2015

Циклы


Contents

Java

import java.util.Scanner;
import java.lang.Math;

public class Task13 {

    public static void main(String[] args) {
        
        Scanner in = new Scanner(System.in);
        
	System.out.println();
        System.out.println(" Рассчет массы деталей ");
        System.out.println("-----------------------");

        System.out.print(" Плотность материала: "); 
	double p = in.nextDouble();

        System.out.print(" Радиус основания: "); 
	double r = in.nextDouble();

        System.out.print(" Предельная высота: "); 
	int h = in.nextInt();

        System.out.println("-----------------------");
        
	for (int i = 1; i <= h; i++) {

	    System.out.printf(" Деталь N%d имеет массу m = %.2f\n", i, p * i * Math.PI * r * r);

	}
    }
}


C++



Pascal




Циклы

Personal tools
Namespaces

Variants
Actions
Navigation
Tools