import [Link].
Scanner;
/** Write a program that asks the user to enter four
coefficients of the function and apply the transformations to
the selected function.
*/
public class Functions {
public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
[Link]("Enter coefficient a: ");
double a = [Link]();
[Link]("Enter coefficient k: ");
double k = [Link]();
[Link]("Enter coefficient d: ");
double d = [Link]();
[Link]("Enter coefficient c: ");
double c = [Link]();
[Link]("\n The equation to the function
is: y = " + a + " f[" + k + "(x - " + d + ")] + " + c + "\n \n"
+ "Transformations:");
// Apply transformations to selected function
if (a >= 1 || a <= -1 ) {
[Link]("\t - Vertical stretch by a
factor of " + a);
if (a <= -1) {
[Link](" and a vertical reflection
over X-axis.");
}
} else if (a < 1 && a > -1) {
[Link]("\t - Vertical compression by a
factor of " + a);
if (a < 0) {
[Link](" and a vertical reflection
over X-axis.");
}
}
if (k >= 1 || k <= -1) {
[Link]("\n" + "\t - Horizontal
compression by a factor of " + (1/k));
if (k <= -1) {
[Link](" and a horizontal
reflection over Y-axis.");
}
} else if (k < 1 && k > -1) {
[Link]("\n" + "\t - Horizontal stretch
by a factor of " + (1/k));
if (k < 0) {
[Link](" and a horizontal
reflection over Y-axis.");
}
}
[Link]("\n");
if (d > 0) {
[Link]("\t - Translation shifted " + d
+ " units to the right");
} else if (d < 0) {
[Link]("\t - Translation shifted " + -
d + " units to the left");
}
if (c > 0) {
[Link](" and " + c + " units up.");
} else if (c < 0) {
[Link](" and " + -c + " units
down.");
}
[Link]();
}