Advertisement
VivianOlivian

Untitled

Sep 16th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. import java.sql.SQLOutput;
  2. import java.util.Scanner;
  3.  
  4. public class Calculator {
  5. public static void main(String[] args) {
  6. printToScreen("Старт программы");
  7. String numberOne = enterNum();
  8. String numberTwo = enterNum();
  9. printToScreen("Принял: " + numberOne);
  10. printToScreen("Принял: " + numberTwo);
  11. int firstNum = stringToInteger(numberOne);
  12. int secondNum = stringToInteger(numberTwo);
  13. int thirdNum = calcDifference(firstNum, secondNum);
  14. printToScreen("Результат:" + thirdNum);
  15. printToScreen("конец программы");
  16. }
  17.  
  18. public static String enterNum() {
  19. Scanner scanner = new Scanner(System.in);
  20. printToScreen("Введите число:");
  21. return scanner.nextLine();
  22. }
  23.  
  24. public static int stringToInteger(String stringData) {
  25. return Integer.parseInt(stringData);
  26. }
  27.  
  28.  
  29. public static int calcDifference(int firstNumber, int secondNumber) {
  30. printToScreen("начинаю считать");
  31. return firstNumber - secondNumber;
  32. }
  33.  
  34. public static void printToScreen(String abraCadaBra) {
  35. System.out.println(abraCadaBra);
  36. }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement