Advertisement
Voldemord

zadaniaJedryka[1a]

Mar 2nd, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.05 KB | None | 0 0
  1. //zadanie 1a
  2. /// --- MAIN ---///
  3.  
  4.  
  5. import java.io.IOException;
  6. import zadanie1a.punktA;
  7. import zadanie1a.punktB;
  8. import zadanie1a.punktC;
  9.  
  10. public class Pwzstar {
  11.    
  12.     public static void main(String[] args) throws IOException {
  13.         punktA.read();
  14.         //punktB.read();
  15.         //punktC.read();
  16.     }
  17.    
  18. }
  19.  
  20.  
  21. /// --- Punkt A---///
  22.  
  23.  
  24. import java.io.*;
  25.  
  26. public class punktA {
  27.    
  28.     public static void read() throws IOException{
  29.         BufferedReader in = new BufferedReader(new InputStreamReader(System.in),1);
  30.         System.out.print("Podaj Argumenty :");
  31.         System.out.println(in.readLine());
  32.     }
  33. }
  34.  
  35.  
  36. /// --- Punkt B---///
  37.  
  38.  
  39. import java.io.*;
  40.  
  41. public class punktB {
  42.  
  43.     static int a, b;
  44.     static BufferedReader in = new BufferedReader(new InputStreamReader(System.in), 1);
  45.  
  46.     public static void read() throws IOException {
  47.         a = scan("A");
  48.         b = scan("B");
  49.         System.out.println(nwd(a, b));
  50.  
  51.     }
  52.  
  53.     private static int scan(String v) throws IOException {
  54.         int x;
  55.         System.out.print("Podaj " + v + ":");
  56.         x = Integer.parseInt(in.readLine());
  57.         return x;
  58.     }
  59.  
  60.     private static String nwd(int a, int b) {
  61.         while (a != b){
  62.             if (a > b){
  63.                 a = a - b;
  64.             } else {
  65.                 b = b - a;
  66.             }
  67.         }
  68.         return "NWD: " + a;
  69.     }
  70. }
  71.  
  72.  
  73. /// --- Punkt C -not finished---///
  74.  
  75.  
  76. import java.io.*;
  77.  
  78. public class punktC {
  79.     static BufferedReader in = new BufferedReader(new InputStreamReader(System.in), 1);
  80.     static float x;
  81.    
  82.     public static void read() throws IOException{
  83.         x = scan("a");
  84.         if(x%1 == 0)
  85.         {
  86.             System.out.println("Work");
  87.         }
  88.         else{
  89.             System.out.println("Podana liczba nie jest całkowita");
  90.         }
  91.     }
  92.     private static float scan(String v) throws IOException {
  93.         float x;
  94.         System.out.print("Podaj " + v + ":");
  95.         x = Float.parseFloat(in.readLine());
  96.         return x;
  97.     }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement