Display a function - Practice Exercises Java Lesson 3: Basic data types Exercise 3.9: Display a function Objetive: Create a program to "draw" the graphic of the function y = (x-4)2 for integer values of x ranging -1 to 8. It will show as many asterisks on screen as the value obtained for "y", like this: ************************* **************** ********* **** * * **** ********* **************** Source Code: JAVA C# public class Main { public static void main(String[] args) { int x,y,j; for (x = -1; x <= 8; x++) { y = (x - 4) * (x - 4); for (j = 0; j < y; j++) { System.out.print("*"); } System.out.println(); } } } Copy Exercise to ClipBoard Copy Code to ClipBoard Exercisey 3.9
More exercises for Lesson 3 Previous Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 Next >>