Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. package pl.dmcs;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6. int a = 0;
  7. int b = 0;
  8. int c = 0;
  9.  
  10. try {
  11. a = Integer.parseInt(args[0]);
  12. b = Integer.parseInt(args[1]);
  13. c = Integer.parseInt(args[2]);
  14. } catch (NumberFormatException nfe) {
  15. System.out.println("Argumenty programu powinny być liczbami! " + nfe);
  16. } catch (ArrayIndexOutOfBoundsException aioobe) {
  17. System.out.println("Liczba argumentów jest za mała!" + aioobe);
  18. }
  19. if (a == 0) {
  20. System.out.print("");
  21. } else {
  22. System.out.print(a + "x^2");
  23. }
  24. if (b == 0) {
  25. System.out.print("");
  26. } else if (b>0){
  27. System.out.print("+" +b + "x");
  28. } else {
  29. System.out.print(b + "x");
  30. }
  31. if (c == 0) {
  32. System.out.print("");
  33. } else if (c>0){
  34. System.out.print("+" +c);
  35. } else{
  36. System.out.print(+c);
  37. }
  38. System.out.println("=0");
  39. System.out.println("Przystępujemy do obliczenia pierwiastków: ");
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement