Given that y=a(x-h)²+k, write an algorithm and draw the corresponding flowchart to solve for Y
Answers
Answer:
ha ha ha
Algorithm:
Step 1: START
Step 2: Declare variables a , x , h , k and y
Step 3: Take input from the user in variable a , x , h and k
Step 4: Calculate y
y = (a * Math.pow(x - h, 2)) + k
Step 5: Print the value of y
Step 6: END
Flowchart:
Flowchart is attached as an image.
Program in JAVA:
import java.util.*;
public class MyClass
{
public static void main(String args[])
{
Scanner Sc = new Scanner(System.in);
double a , x , h , k , y;
System.out.print("Enter the value of a : ");
a = Sc.nextDouble();
System.out.print("Enter the value of x : ");
x = Sc.nextDouble();
System.out.print("Enter the value of h : ");
h = Sc.nextDouble();
System.out.print("Enter the value of k : ");
k = Sc.nextDouble();
y = (a * Math.pow(x - h , 2)) + k;
System.out.print("Value of y = " + y);
}
}
Output:
Enter the value of a : 10
Enter the value of x : 20
Enter the value of h : 30
Enter the value of k : 40
Value of y = 1040.0