aLT22

java naarabotki

Dec 14th, 2014
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.92 KB | None | 0 0
  1. //Создайте программу, которая вычислит выражение 20ˣ⅓+158² и выведет результат на экран.
  2. /*class Main {
  3.     public static void main (String [] args){
  4.         double slag1 = 20.0*(1.0/3.0);
  5.         int slag2 = 158*158;
  6.         double result = slag1 + slag2;
  7.         System.out.println(slag1 + " + " + slag2 + " = " + result);
  8.     }
  9. }*/
  10. //В переменной n хранится двузначное число. Создайте программу, вычисляющую и выводящую на экран сумму цифр n.
  11. /*class Main {
  12.     public static void main (String [] args) {
  13.         int n = 89;
  14.         int slag1 = (int) n/10;
  15.         int slag2 = (int) n%10;
  16.         System.out.println(slag1 + " + " + slag2 + " = " + n);
  17.     }
  18. }*/
  19. //142. Треугольник задан координатами своих вершин. Составить программу вычисления его площади.
  20. // Nechto inoe, potok vvoda, test
  21. /*import java.util.*;
  22. public class Main{
  23.     public static void main (String [] args){
  24.        Scanner reader = new Scanner(System.in);
  25.         System.out.println("Vvedite svoe pervoe soobshenie");
  26.         String a;
  27.         a = reader.nextLine();
  28.         System.out.println(a);
  29.     }
  30. }*/
  31. /*class Main {
  32.     public static void main(String[] args) {
  33.         java.util.ArrayList<Integer> mas = new java.util.ArrayList<Integer>();
  34.         mas.add(5);
  35.         mas.add(10);
  36.         mas.add(15);
  37.         for (int i = 0; i < mas.size (); i++) {
  38.             System.out.print(mas.get(i) + " ");
  39.         }
  40.     }
  41. }*/
  42. // Вычисление выражения стр 18 № 5 Ускова
  43. /*import java.util.Scanner;
  44.  
  45. public class Main{
  46.     public static int x;
  47.     public static void main (String [] args){
  48.         FirstEqual a = new FirstEqual();
  49.         SecondEqual b = new SecondEqual();
  50.         Scanner reader = new Scanner(System.in);
  51.         System.out.print("Введите х: ");
  52.         x = reader.nextInt();
  53.         if ((x*x) - x <= 1){
  54.             System.out.print(a.Equal(x));
  55.         }
  56.         else if ((x*x) - x > 1){
  57.             System.out.print(b.Equal(x));
  58.         }
  59.         else {
  60.             System.out.println("Error");
  61.         }
  62.     }
  63. }
  64.  
  65. class FirstEqual{
  66.     public int Equal (int x){
  67.         return x*x*x - 3*x + 8;
  68.     }
  69. }
  70.  
  71. class SecondEqual{
  72.     public double Equal (int x){
  73.         return 1/(x*x*x - 3*x + 8);
  74.     }
  75. }*/
  76. // По заданным значениям вычислить значения u стр 18 пункт b)
  77. /*import java.util.Scanner;
  78.  
  79. public class Main{
  80.     public static int x,y,a,b,c,d;
  81.     public static void main (String [] args){
  82.         Scanner reader = new Scanner(System.in);
  83.         System.out.print("Введите a,b,c,d для определения интервалов/отрезков: ");
  84.         a = reader.nextInt();
  85.         b = reader.nextInt();
  86.         c = reader.nextInt();
  87.         d = reader.nextInt();
  88.         FirstEqual a1 = new FirstEqual();
  89.         SecondEqual a2 = new SecondEqual();
  90.         ThirdEqual a3 = new ThirdEqual();
  91.         System.out.print("Введите числа x , y: ");
  92.         x = reader.nextInt();
  93.         y = reader.nextInt();
  94.         if (((a*x + b*y) >= c) && ((a*x + b*y) < d)){
  95.             System.out.print(a1.Equal(x,y,a,b));
  96.         }
  97.         else if ((a*x + b*y) < c){
  98.             System.out.print(a2.Equal(x,y));
  99.         }
  100.         else if ((a*x + b*y) >= d){
  101.             System.out.print(a3.Equal(x,y));
  102.         }
  103.         else {
  104.             System.out.println("ERROR");
  105.         }
  106.     }
  107. }
  108.  
  109. class FirstEqual{
  110.     public int Equal(int x, int a, int y, int b){
  111.         return a*x + b*y;
  112.     }
  113. }
  114.  
  115. class SecondEqual{
  116.     public int Equal (int t, int q){
  117.         return t + q;
  118.     }
  119. }
  120.  
  121. class ThirdEqual{
  122.     public int Equal (int a, int b){
  123.         return 1 - a - b;
  124.     }
  125. }*/
Advertisement
Add Comment
Please, Sign In to add comment