Advertisement
Guest User

Untitled

a guest
Jan 26th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package ympyra;
  7.  
  8. /**
  9. *
  10. * @author 1301402
  11. */
  12. public class Ympyra {
  13.  
  14. /**
  15. * @param args the command line arguments
  16. */
  17. public static void main(String[] args) {
  18. Scanner nappis = new Scanner(System.in);
  19. double pit;
  20.  
  21. System.out.print("Anna ympyrän sade: ");
  22. pit = nappis.nextDouble();
  23.  
  24. ympyra k1 = new ympyra(pit);
  25.  
  26. System.out.println("Piiri on"+k1.piiri());
  27.  
  28. System.out.println("Ala on "+k1.ala());
  29.  
  30. }
  31.  
  32. }
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41. /*
  42. * To change this license header, choose License Headers in Project Properties.
  43. * To change this template file, choose Tools | Templates
  44. * and open the template in the editor.
  45. */
  46.  
  47. /**
  48. *
  49. * @author 1301402
  50. */
  51. public class Ympyra_2 {
  52.  
  53. //luokkamuuttujat
  54. public double r, A, p;
  55.  
  56.  
  57. //muodostin
  58. ympyra() {
  59. r = 0;
  60. }
  61.  
  62. public ympyra(double d) {
  63. this.r = r;
  64. }
  65. //tilavuus
  66. double piiri() {
  67. p = 2*Math.PI*r;
  68. return(p);
  69. }
  70. //pinta-ala
  71. double ala() {
  72. A = Math.PI*r*r;
  73. return(A);
  74.  
  75.  
  76. }
  77.  
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement