Хелпикс

Главная

Контакты

Случайная статья





Курс “Введение в программирование”, Тема 3, Задание 2



Курс “Введение в программирование”, Тема 3, Задание 2

 

Варианты решения задач

 

1) Scanner input = new Scanner(System.in);

System.out.println("Vvedite 5 slov:");

 

String word1 = input.next();

String word2 = input.next();

String word3 = input.next();

String word4 = input.next();

String word5 = input.next();

 

String result =word1 + " " + word2 + " " + word3 + " " + word4 + " " + word5;

System.out.println( result );

 

2) Scanner input = new Scanner(System.in);

System.out.println("Vvedite 5 chisel:");

 

double a = input.nextDouble();

double b = input.nextDouble();

double c = input.nextDouble();

double d = input.nextDouble();

double e = input.nextDouble();

 

double summ = a + b + c + d + e;

double ostatokDelen = summ % a;

                       

boolean result = ostatokDelen > 0 && ostatokDelen < a / 2;

System.out.println(result);

 

3) Scanner input = new Scanner(System.in);

                       

System.out.println("Vvedite 2 chisla:");

                       

double first = input.nextDouble();

double second = input.nextDouble();

                       

System.out.println("Vvedite edinicu izmereniya:");

                       

String word = input.next();

double summ = first + second;

String result = first + word + " + " + second + word + " = " + summ + word;

                                               

System.out.println(result);

 

 

4) Scanner input = new Scanner(System.in);

                       

System.out.println("Vvedite 3 chisla:");

                       

double first = input.nextDouble();

double second = input.nextDouble();

double third = input.nextDouble();

                       

boolean result = first > second + third || third * third > first + second; 

                                               

System.out.println(result);

 

5) Scanner input = new Scanner(System.in);

                       

System.out.println("Vvedite 6 chisel:");

                       

double q = input.nextDouble();

double w = input.nextDouble();

double e = input.nextDouble();

double r = input.nextDouble();

double t = input.nextDouble();

double y = input.nextDouble();

                       

boolean result = (r+t+y) % w > q-t || w*w + r*r > (q+y)*(q+y) || e == 10;

                                               

System.out.println(result);

 

6)  Scanner input = new Scanner(System.in);

                       

System.out.println("Vvedite 10 chisel:");

                       

double a1 = input.nextDouble();

double a2 = input.nextDouble();

double a3 = input.nextDouble();

double a4 = input.nextDouble();

double a5 = input.nextDouble();

double a6 = input.nextDouble();

double a7 = input.nextDouble();

double a8 = input.nextDouble();

double a9 = input.nextDouble();

double a10 = input.nextDouble();

 

double summ1_5 = a1+a2+a3+a4+a5;

double summ1_10 = summ1_5+a6+a7+a8+a9+10;

boolean result = summ1_5 <= a9*a9 - a10*a10 || summ1_10 <= 100;

                                               

System.out.println(result);

 

 

7) Scanner input = new Scanner(System.in);

                       

System.out.println("Vvedite 6 chisel:");

                       

double q = input.nextDouble();

double w = input.nextDouble();

double e = input.nextDouble();

double r = input.nextDouble();

double t = input.nextDouble();

double y = input.nextDouble();

                       

boolean result = q > 3 && q < w && w < e && e < r && r < t && t < y;

                                               

System.out.println(result);

        

8) Scanner input = new Scanner(System.in);

                       

       System.out.println("Vvedite 6 chisel:");

                       

       double q = input.nextDouble();

       double w = input.nextDouble();

       double e = input.nextDouble();

       double r = input.nextDouble();

       double t = input.nextDouble();

       double y = input.nextDouble();

                       

       boolean result = q + q/2 <= w &&

                                w + w/2 <= e &&

                               e + e/2 <= r &&

                               r + r/2 <= t &&

                               t + t/2 <= y &&

                               q * 2 <= y;

                                               

       System.out.println(result);

 

9) Scanner input = new Scanner(System.in);

                       

System.out.print("Vvedite A:");

double A = input.nextDouble();

System.out.print("Vvedite B:");

double B = input.nextDouble();

System.out.print("Vvedite C:");

double C = input.nextDouble();

System.out.print("Vvedite D:");

double D = input.nextDouble();

System.out.print("Vvedite E:");

double E = input.nextDouble();

double F = input.nextDouble();

 

double buffer;

                       

buffer = A;

A = F;

F = buffer;

                       

buffer = B;

B = E;

E = buffer;

                       

buffer = C;

C = D;

D = buffer;

                       

System.out.println(" A=" + A +

                   " B=" + B +

                   " C=" + C +

                   " D=" + D +

                   " E=" + E +

                   " F=" + F);

 

 

9.1) Scanner input = new Scanner(System.in);

                 

System.out.print("Vvedite A:");

double A = input.nextDouble();

System.out.print("Vvedite B:");

double B = input.nextDouble();

                                         

A = A + B;

B = A - B;

A = A - B;

                                         

System.out.println(" A=" + A + " B=" + B);

 

 

10)  Scanner input = new Scanner(System.in);

                       

       System.out.println("Vvedite kolichestvo metrov:");

       double metru = input.nextDouble();

       double kilometru = metru / 1000;

       System.out.print(metru + "m = " + kilometru + "km");

 

 

11)  Scanner input = new Scanner(System.in);

                       

System.out.println("Vvedite temp v Cels :");

double celsii = input.nextDouble();

double kelvin = celsii + 273.15;

double farengeit = celsii * 1.8 + 32;

System.out.println(celsii + "c = " + kelvin + "K ");

System.out.println(celsii + "c = " + farengeit + "F");

           

 

12) Scanner input = new Scanner(System.in);

           

System.out.println("Vvedite 3 storoni treugolnika:");

System.out.print("Storona1:");

double str1 = input.nextDouble();

System.out.print("Storona2:");

double str2 = input.nextDouble();

System.out.print("Storona3:");

double str3 = input.nextDouble();

                       

boolean isExists = str1 + str2 > str3 && str1 + str3 > str2 && str2 + str3 > str1;

           

System.out.println(isExists);

 

 

13) Scanner input = new Scanner(System.in);

                       

System.out.println("Vvedite 3 ugla treugolnika:");

System.out.print("Ugol1:");

double ugl1 = input.nextDouble();

System.out.print("Ugol2:");

double ugl2 = input.nextDouble();

System.out.print("Ugol3:");

double ugl3 = input.nextDouble();

                       

boolean isExists = ugl1 + ugl2 + ugl3 >= 180;

           

System.out.println(isExists);

 

 

 

14)  Scanner input = new Scanner(System.in);

                       

System.out.print("Vvedite inches:");

double inches = input.nextDouble();

System.out.print("Vvedite kilometers:");

double kilom = input.nextDouble();

                       

double inchesToSm = inches * 2.54;

double kilomToSm = kilom * 100000;

boolean result = inchesToSm >= kilomToSm;

                                               

System.out.println(result);

 

 

15) Scanner input = new Scanner(System.in);

                       

System.out.println("Vvedite koeffs urovneniya :");

System.out.print("a:");

double a = input.nextDouble();

System.out.print("b:");

double b = input.nextDouble();

System.out.print("c:");

double c = input.nextDouble();

 

double discriminant = b * b - 4 * a * c;

                       

boolean isKoefsOk = a != 0;

boolean isKorni = isKoefsOk && discriminant < 0;

 

System.out.println("Vvedennue koeffs podhodyat? - " + isKoefsOk);

System.out.println("U urovneniya est korni? - " + isKorni);

 

 



  

© helpiks.su При использовании или копировании материалов прямая ссылка на сайт обязательна.