AKT kasb ta’limi fakulteti 623_21 guruh talabasi Baxtiyorov Muhammad qodir
1-topshiriq //1-savol//
Savol:
. Uzunlik birliklari berilgan 1-desimetr, 2-kilometr, 3-metr, 4-millimetr, 5- santimetr. Kesma uzunligi berilgan xaqiqiy son va 1 dan 5 gacha sonlarda uzunlik birligi berilgan kesmaning uzunligini metrda chiqaruvchi dastur tuzing.
Dastur codi
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int a,dt = 0;
Scanner k = new Scanner(System.in);
System.out.println("o'lchamni qaysi birlikda kiritmoqchisiz ? \n");
System.out.println("millimetrda bo'lsa 1 ni ");
System.out.println("santimetrda bo'lsa 2 ni ");
System.out.println("detsimetrda bo'lsa 3 ni ");
System.out.println("metrda bo'lsa 4 ni ");
System.out.println("kilometrda bo'lsa 5 ni kiriting ");
a = k.nextInt();
System.out.print("o'lchamni kiriting ");
dt=k.nextInt();
switch(a){
case 1: System.out.println("siz kiritgan qiymat "+dt+" mm uni metr o'lchov birligiga o'girsak "+(dt/1000)+" m bo'ladi"); break;
case 2: System.out.println("siz kiritgan qiymat "+dt+" sm uni metrga o'lchov birligiga o'girsak "+(dt/100)+" m bo'ladi"); break;
case 3: System.out.println("siz kiritgan qiymat "+dt+" dm uni metrga o'lchov birligiga o'girsak "+(dt/10)+" m bo'ladi"); break;
case 4: System.out.println("siz kiritgan qiymat "+dt+" m uni metrga o'lchov birligiga o'girsak "+dt+" m bo'ladi "); break;
case 5: System.out.println("siz kiritgan qiymat "+dt+" km uni metrga o'lchov birligiga o'girsak "+(dt*1000)+" m bo'ladi"); break;
default: System.out.println("faqat 1 dan 5 gacha bo'lgan raqamlarni kiritishingiz mumkin");}
}
}
Natijasi
2-topshiriq //2-savol//
n butun soni berilgan ismingizni n ta qatorda chiqaruvchi dastur tuzing.(1 qatorda 1 ta, 2 qatorda 2 ta, n qatorda n ta)
Dastur codi
package com.company;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner k = new Scanner(System.in);
int n;
System.out.print("qatorlar sonini kiriting n = ");
n = k.nextInt();
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print("Muhammad qodir ");
}
System.out.println();
}
}
}
Natijasi
3-topshiriq //1-savol//
s,t haqiqiy sonlar berilgan. G(1.2,s)+G(t,s)+G(2s−1,st) ni xisoblang
Dastur codi
package com.company;
import java.util.Scanner;
public class Main {
private static double g;
static double myfunctions(double a, double b){
g=((a*a)+(b*b))/(a*a+2*a*b+3*b*b+4);
return g;
}
public static void main(String[] args) {
double s,t,g1,g2,g3;
Scanner k = new Scanner(System.in);
System.out.print("s = ");
s=k.nextDouble();
System.out.print("t = ");
t=k.nextDouble();
g1=myfunctions(1.2,s);
g2=myfunctions(t,s);
g3=myfunctions(2*s-1,s*t);
System.out.print("Natija = ");
System.out.print(g1+g2+g3);
}
}
Natija
Do'stlaringiz bilan baham: |