daily pastebin goal
92%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package Lesson11;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Ex2 {
  6.  
  7.     static int firstUserNumber;
  8.     static int secondUserNumber;
  9.     int userNumbers[];
  10.  
  11.     public static void main(String[] args) {
  12.         Ex2 k = new Ex2();
  13.         k.getNumbers();
  14.         k.Calculation(firstUserNumber, secondUserNumber);
  15.  
  16.     }
  17.  
  18.     private int[] getNumbers() {
  19.         Scanner sc = new Scanner(System.in);
  20.         System.out.print("Podaj liczbę: ");
  21.         firstUserNumber = sc.nextInt();
  22.         System.out.print("Podaj liczbę: ");
  23.         secondUserNumber = sc.nextInt();
  24.         return userNumbers;
  25.     }
  26.  
  27.     private void Calculation (int firstUserNumber, int secondUserNumber) {
  28.         double result = (double) firstUserNumber / secondUserNumber;
  29.         int mod = (int) ((int) firstUserNumber % secondUserNumber);
  30.         if(mod > 0) {
  31.             System.out.println("Reszta z dzielenia: " + mod);
  32.             System.out.print("Wynik: " + result);
  33.         }
  34.         else {
  35.             double result1 = (double) result;
  36.             System.out.print("Wynik: " + result1);
  37.         }
  38.     }
  39. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top