Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package ympyra;
- /**
- *
- * @author 1301402
- */
- public class Ympyra {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- Scanner nappis = new Scanner(System.in);
- double pit;
- System.out.print("Anna ympyrän sade: ");
- pit = nappis.nextDouble();
- ympyra k1 = new ympyra(pit);
- System.out.println("Piiri on"+k1.piiri());
- System.out.println("Ala on "+k1.ala());
- }
- }
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author 1301402
- */
- public class Ympyra_2 {
- //luokkamuuttujat
- public double r, A, p;
- //muodostin
- ympyra() {
- r = 0;
- }
- public ympyra(double d) {
- this.r = r;
- }
- //tilavuus
- double piiri() {
- p = 2*Math.PI*r;
- return(p);
- }
- //pinta-ala
- double ala() {
- A = Math.PI*r*r;
- return(A);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement