Advertisement
PiotrTwardowski

Piotr Twardowsi 4bTI/2 nr.27 Zadania na lekcji

Dec 9th, 2021
835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.13 KB | None | 0 0
  1. Piotr Twardowski 4bTI/2 nr.27
  2.  
  3. Zad.1
  4.  
  5. const prompt=require('prompt-sync')();
  6.  
  7. const a = +prompt("Podaj promien okregu: ");
  8. let pole= (3,14)*(a*a);
  9. let obwod= 2*(3,14)*a;
  10.  
  11. console.log("Pole wynosi: "+pole);
  12. console.log("Obwod wynosi: "+obwod);
  13.  
  14.  
  15. Zad.2
  16.  
  17. const prompt=require('prompt-sync')();
  18.  
  19. suma1=0;
  20. suma2=0;
  21. let pot2;
  22. let pot3;
  23. let i;
  24.  
  25. const a = parseInt(+prompt("Podaj poczatek przedzialu: "));
  26. const b = parseInt(+prompt("Podaj koniec przedzialu: "));
  27.  
  28. for((i=a);i<=b;i++)
  29. {
  30.     pot2=i*i;
  31.     pot3=i*i*i;
  32.     console.log("Liczba :" +i+ " kwadrat: "+ pot2+" szescian: "+pot3);
  33.     suma1=suma1+pot2;
  34.     suma2=suma2+pot3;
  35. }
  36. console.log("Suma kwadratów wynosi: "+suma1+" suma szescianow: "+suma2);
  37.  
  38.  
  39.  
  40. Zad.3
  41.  
  42.  
  43. const prompt=require('prompt-sync')();
  44.  
  45. let i=0;
  46. let j=0;
  47. let dlu = parseInt(prompt("Podaj dlugosc: "));
  48. let wys = parseInt(prompt("Podaj wysokosc: "));
  49.  
  50. if(dlu==0 && wys==0)
  51. {
  52.     console.log("Prosze podac liczby wieksze od zera.");
  53. }
  54. else
  55. do {
  56.     console.log ("*");
  57.     i++;
  58.     if (i==dlu)
  59.     {
  60.         j++;
  61.         i=0;
  62.         console.log("")
  63.     };
  64. }
  65. while (j<wys);
  66. let obw = dlu*2+wys*2;
  67. let pol = dlu*wys;
  68. console.log("")
  69. console.log ("Obwód wynosi "+ obw + " pole: " + pol );
  70.  
  71.  
  72.  
  73. zad.4
  74.  
  75.  
  76. const prompt=require('prompt-sync')();
  77.  
  78. let a= +prompt ("Podaj swoje liczby ");
  79. let suma=0;
  80. let b=0;
  81.  
  82. while(a!=0)
  83. {
  84.     if(a%10==0)
  85.         {
  86.             b++;
  87.             a=a/10;
  88.         }
  89.         else if (a%10!=0)
  90.         {
  91.             while (a%10!=0)
  92.             {
  93.                 suma++;
  94.                 a--;
  95.             }
  96.             a=a/10;
  97.             b++;
  98.         }
  99.  
  100. }
  101. console.log("Suma wpisanych cyfr: "+suma);
  102. console.log("Ilosc wpisanych liczb: "+b);
  103.  
  104.  
  105. zad.5
  106.  
  107. const prompt=require('prompt-sync')();
  108.  
  109. let n= +prompt ("Podaj kwote jaka chcez przeznaczyc na prezenty: ");
  110. let i=0;
  111. while(n!=0)
  112. {
  113.     let cena=+prompt("Podaj kwote swojego prezentu: ");
  114.     n=n-cena;
  115.     if(n<0)
  116.     {
  117.         console.log("Kup cos tanszego, brakuje ci pieniedzy.");
  118.         n=n+cena;
  119.     }
  120.     i++;
  121. }
  122. console.log("Za podana kwote kupiles: "+i+" upominkow.");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement