Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.InputMismatchException;
- public class prog6{
- public static void main() {
- boolean run = true;
- while(run) {
- try {
- Scanner in = new Scanner(System.in);
- /* Program wyświetlający wartość wyrażenia ((x+3)/(x+61)-2)*3 – x */
- System.out.print ("Podaj wartość x:");
- double x = in.nextDouble();
- if (x==-61) {
- System.out.println ("BŁĄD DANYCH! - Mianownik nie może wynosić 0"); }
- else {
- double wyr = ((x+3)/(x+61)-2)*3-x;
- System.out.println ("Wartość wyrażenia ((x+3)/(x+61)-2)*3 – x = " + String.format( "%.5f", wyr ));
- }
- }
- catch (InputMismatchException e) {
- System.out.println ("BŁĄD DANYCH! - Wymagane dane liczbowe");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement