Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //KOPIRAJT MagnusArias (c)
- class ProgsRun{
- public static boolean isNumeric(String input){
- try {
- Double.parseDouble(input);
- return true;
- }
- catch(NumberFormatException e)
- {
- return false;
- }
- }
- public static void main(String[] args)
- {
- if (args.length == 3){
- if ((isNumeric(args[0])) && (isNumeric(args[1])) && (isNumeric(args[2])))
- {
- double a = Double.parseDouble(args[0]);
- double b = Double.parseDouble(args[1]);
- double c = Double.parseDouble(args[2]);
- System.out.println("\nPodane argumenty: a = "+a +" b = "+b +" c = "+c);
- if (a==0)
- {
- System.out.println("\nRownanie jest liniowe");
- System.exit(1);
- }
- double delta = (b*b) - (4*a*c);
- System.out.println("\nDelta = "+delta);
- if (delta > 0)
- {
- double x1 = (-b - Math.sqrt(delta))/2*a;
- double x2 = (-b + Math.sqrt(delta))/2*a;
- System.out.println("\nRozwiazania: x1 = "+x1 + " x2 = "+x2);
- }
- else if (delta == 0)
- {
- double x0 = -b/(2*a);
- }
- else
- {
- System.out.println("\nDelta ujemna, brak rozwiazan");
- }
- }
- else
- {
- System.out.println("Co najmniej jeden z argumentow nie jest liczba");
- }
- }
- else
- {
- System.out.println("\n\nPodano za malo lub za duzo argumentow");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement