Advertisement
Guest User

zad6

a guest
Dec 17th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.InputMismatchException;
  3. public class prog6{
  4. public static void main() {
  5. boolean run = true;
  6. while(run) {
  7. try {
  8. Scanner in = new Scanner(System.in);
  9. /* Program wyświetlający wartość wyrażenia ((x+3)/(x+61)-2)*3 – x */
  10.  
  11. System.out.print ("Podaj wartość x:");
  12. double x = in.nextDouble();
  13.  
  14. if (x==-61) {
  15. System.out.println ("BŁĄD DANYCH! - Mianownik nie może wynosić 0"); }
  16. else {
  17. double wyr = ((x+3)/(x+61)-2)*3-x;
  18. System.out.println ("Wartość wyrażenia ((x+3)/(x+61)-2)*3 – x = " + String.format( "%.5f", wyr ));
  19. }
  20. }
  21. catch (InputMismatchException e) {
  22. System.out.println ("BŁĄD DANYCH! - Wymagane dane liczbowe");
  23. }
  24. }
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement