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 ;
Masalaning yechilishi:
3–misol.
x ning qiymatida f = 2x2 + 3x – 9 funnktsiyasinig qiymatini aniqlovchi dasturni
Java tilida tuzamiz :
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);
}
}
Na’tiyja :
x=5
f=56.0
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 :
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);
}
}
Na’tiyja :
v=5
a=3
t=4
S=44.0
Screenshot :
Do'stlaringiz bilan baham: |