Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Lab;
- import java.util.*;
- public class Lab {
- Scanner in;
- float a,b,c;
- float x1,x2,dx,delta;
- float xa,xb;
- public Lab() {
- in = new Scanner(System.in);
- System.out.print("Podaj a: ");
- a = in.nextFloat();
- System.out.print("Podaj b: ");
- b = in.nextFloat();
- System.out.print("Podaj c: ");
- c = in.nextFloat();
- System.out.print("Podaj x1: ");
- x1 = in.nextFloat();
- System.out.print("Podaj x2: ");
- x2 = in.nextFloat();
- System.out.print("Podaj dx: ");
- dx = in.nextFloat();
- delta = (float) (Math.pow(a, 2) - 4*a*c);
- System.out.format("Postać równania %.1fx^2 + %.1fx + %.1f\n",a,b,c);
- System.out.format("Wypisanie wartosci od %.2f do %.2f z skokiem %.2f\n",x1,x2,dx);
- if(delta>=0){
- xa = (float)(b+Math.sqrt(delta))/2*a;
- System.out.format("xa = %.2f\n",xa);
- if(delta>0){
- xb = (float)(b-Math.sqrt(delta))/2*a;
- System.out.format("xa = %.2f\n",xb);
- }
- }
- System.out.format("====================\n");
- System.out.format("| %6s | %6s |\n","X","Y");
- for(float i=x1;i<x2;i++){
- System.out.format("| %6.2f | %6.2f |\n",i,(a*(i*i)+(b*i)+c));
- }
- System.out.format("====================\n");
- }
- public static void main(String[] args) {
- new Lab();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement