Tayyorladi: Fayziboyev Abbos


Download 182.23 Kb.
Sana26.11.2021
Hajmi182.23 Kb.
#177482
Bog'liq
3- tajriba ishi


3- TAJRIBA ISHI

Tayyorladi: Fayziboyev Abbos

Tekshirdi: Nilufar Mirzayeva

Toshkent – 2020

Reja:


  1. To’rt o'zgaruvchiga ega bo'lgan sinf yarating. Displey funktsiyasini va ushbu o'zgaruvchilarni o'zgartirish funksiyasini qo'shing. Ushbu o'zgaruvchilar qiymatlari yig'indisini topadigan va shu to’rt o'zgaruvchining eng katta qiymatini topadigan funksiyani qo'shing.

  2. Belgilangan diapazonda qiymatini bittaga oshirishi yoki kamaytirishi mumkin bo'lgan o'nli hisoblagichni amalga oshiradigan sinfni tavsiflang. Standart qiymatlar va ixtiyoriy qiymatlar bilan hisoblagichni ishga tushirishni ta'minlang. Hisoblagich ikkita usulga ega bo’lishi kerak:

  • oshirish va kamaytirish;

  • hozirgi holatini olishga imkon berish.

Sinfning barcha imkoniyatlarini namoyish etadigan dastur yozing.

MASALANING JAVA DASTURLASH TILIDAGI KODI :

import java.awt.*;
import java.util.Scanner;

public class MyClassForDUVP {


private int firstVareable, secondvarieable, thirdvarieable, fourthvariable;

public int getFirstVareable() {


return firstVareable;
}

public void setFirstVareable(int firstVareable) {


this.firstVareable = firstVareable;
}

public int getSecondvarieable() {

return secondvarieable;
}

public void setSecondvarieable(int secondvarieable) {

this.secondvarieable = secondvarieable;
}

public int getThirdvarieable() {


return thirdvarieable;
}

public void setThirdvarieable(int thirdvarieable) {


this.thirdvarieable = thirdvarieable;
}

public int getFourthvariable() {


return fourthvariable;
}

public void setFourthvariable(int fourthvariable) {


this.fourthvariable = fourthvariable;
}

public int findMax(int firstVareable, int secondvarieable,


int thirdvarieable, int fourthvariable) {
return Math.max(Math.max(firstVareable, secondvarieable),
Math.max(thirdvarieable, fourthvariable));
}

public int adder() {


return firstVareable + secondvarieable + thirdvarieable + fourthvariable;
}

public int Hisoblagich(int n, int m){


if (n == 1){
return ++n;
} else if (n == 2)
{
return --n;
} else
{
return n;
}
}

public static void main(String[] args) {


Scanner scanner = new Scanner(System.in);
MyClassForDUVP myClassForDUVP = new MyClassForDUVP();
myClassForDUVP.setFirstVareable(1);
myClassForDUVP.setSecondvarieable(2);
myClassForDUVP.setThirdvarieable(3);
myClassForDUVP.setFourthvariable(4);

System.out.println("1 variable : " + myClassForDUVP.getFirstVareable());


System.out.println("2 variable : " + myClassForDUVP.getSecondvarieable());
System.out.println("3 variable : " + myClassForDUVP.getThirdvarieable());
System.out.println("4 variable : " + myClassForDUVP.getFourthvariable());
System.out.println("\nMax - > : " + myClassForDUVP.findMax(myClassForDUVP.firstVareable,
myClassForDUVP.secondvarieable, myClassForDUVP.thirdvarieable,
myClassForDUVP.fourthvariable));

System.out.println(myClassForDUVP.Hisoblagich(myClassForDUVP.firstVareable, 1));


System.out.println(myClassForDUVP.Hisoblagich(myClassForDUVP.secondvarieable, 2));
System.out.println(myClassForDUVP.Hisoblagich(myClassForDUVP.thirdvarieable, 3));

}
}


NATIJA:
Download 182.23 Kb.

Do'stlaringiz bilan baham:




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