6.3.16. Napisati program koji za ucitano x ispisuje vrijednost y po formuli: a) y = kx + b b) y = ax2 + bx + c c) y = tg x d) y = log x .
Listing programa:
package Zadatak;
import java.util.Scanner;
public class P06411149 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double y;
System.out.print("Unesite brojeve: ");
double x = input.nextDouble();
double a = input.nextDouble();
double b = input.nextDouble();
double c = input.nextDouble();
double k = input.nextDouble();
y = k * x + b;
System.out.print("Rez pod a): " + y);
System.out.println();
y = a * x * 2 + b * x + c;
System.out.print("Rez pod b): " + y);
System.out.println();
y = Math.tan(x);
System.out.print("Rez pod c): " + y);
System.out.println();
y = Math.log(x);
System.out.print("Rez pod d): " + y);
}
}
Ispis na ekranu:
Index
|