«Dasturiy injiniringi» mutaxassisligi 1-kurs 104-19 guruh talabasi Aytmuratov Ruslanbekning


Download 34.75 Kb.
bet3/3
Sana05.04.2023
Hajmi34.75 Kb.
#1274826
1   2   3
Bog'liq
3-lab(Dasturlash)

Masalaning qo’yilishi:

3–misol: x ning qiymatida f = 2x2 + 3x – 9 funktsiyasinig qiymatini hisoblang ;
41–misol: Boshlang’ich tezligi 0 m/s bolgan avtomobil m/s2 tezlanish bilan
harakatlanib boshladi. Avtomobil t sek vaqitta qancha jo’l (m) bosishini
aniqlang ;



  1. Masalaning yechilishi:



3–misol.
x ning qiymatida f = 2x2 + 3x – 9 funnktsiyasinig qiymatini aniqlovchi dasturni
Java tilida tuzamiz :



  1. Dastu’r kodi:

package misol3;


import java.util.Scanner;
public class Misol3 {

public static void main(String[] args) {


Scanner in=new Scanner(System.in);
double x,f;
System.out.print("x=");
x = in.nextDouble();
f = 2*Math.pow(x,2) + 3*x - 9;
System.out.println("f="+f);
}
}

  1. Na’tiyja :

x=5
f=56.0



  1. Screenshot:



41 – misol :
Boshlang’ich tezligi 0 m/s bolgan avtomobil m/s2 tezlanish bilan
harakatlanib boshladi. Avtomobil t sek vaqitta qancha jo’l (m) bosishini
aniqlovchi Java tilida dastur tu’zamiz :

  1. Dastur kodi :

package misol41;


import java.util.Scanner;
public class Misol41 {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
double v,a,t,S;
System.out.print("v=");
v = in.nextDouble();
System.out.print("a=");
a = in.nextDouble();
System.out.print("t=");
t = in.nextDouble();
S = v*t + a*Math.pow(t,2)/2;
System.out.println("S="+S);
}
}

  1. Na’tiyja :

v=5
a=3


t=4
S=44.0



  1. Screenshot :




Download 34.75 Kb.

Do'stlaringiz bilan baham:
1   2   3




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling