Практикум по программированию. Основы. Ветвление. Поле сферы

From AsIsWiki
Revision as of 15:15, 4 April 2015 by Alex (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Ветвление


Contents

Java

import java.util.Scanner;

public class Task17 {

    public static void main(String[] args) {
        
        Scanner in = new Scanner(System.in);
        
	System.out.println();
        System.out.println("     Расчет напряженности      ");
        System.out.println(" электростатического поля сферы ");
        System.out.println("--------------------------------");

        System.out.print(" Введите заряд сферы Q: "); 
	double q = in.nextDouble();

        System.out.print(" Введите радиус сферы R: "); 
	double r = in.nextDouble();

        System.out.println(" Расстояние от центра сферы"); 
        System.out.print(" до исследуемой точки L: "); 
	double l = in.nextDouble();

        System.out.println("--------------------------------");
        
	double e;
                    
	if (l >= r) {
	    e = q / (l * l);
	} else {
	    e = 0;
	}

	System.out.printf(" Напряженность поля E = %.2E в/м\n", e);
    }
}


C++



Pascal




Ветвление

Personal tools
Namespaces

Variants
Actions
Navigation
Tools