Hello there
I have been giving a assignment at school were i have to be able to say what i want to. like 2x+3 or something like that. i'm in the beginning of programming and just started a month ago.
i have only mangede to make straigth slopes and straigth lines where i say they start from and end.
my teacher want me to make a program that gonna look something likes this:
java.jpg
with is an sinus curve. what should i do to make something like that?
Here is what i have been making. is there someone who can point me in the right direction?
import java.util.*; public class Opgave4_ChristianSørensen{ public static void main (String [] args) { System.out.println(" y-aksen"); System.out.println("- - - - - - - - - + + + + + + + + +"); System.out.println("9,8,7,6,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9"); slope(0, 5); slope(6, -7); straight(5, -5); System.out.println(); slope(5, -2); } public static void slope(int Start, int end) { if (Start <= end) { for (int i = Start; Start<= end; Start++){ if (Start == -9) System.out.println("x |"); else if (Start == -8) System.out.println(" x |"); else if (Start == -7) System.out.println(" x |"); else if (Start == -6) System.out.println(" x |"); else if (Start == -5) System.out.println(" x |"); else if (Start == -4) System.out.println(" x |"); else if (Start == -3) System.out.println(" x |"); else if (Start == -2) System.out.println(" x |"); else if (Start == -1) System.out.println(" x |"); else if (Start == 0) System.out.println(" x"); else if (Start == 1) System.out.println(" | x"); else if (Start == 2) System.out.println(" | x"); else if (Start == 3) System.out.println(" | x"); else if (Start == 4) System.out.println(" | x"); else if (Start == 5) System.out.println(" | x"); else if (Start == 6) System.out.println(" | x"); else if (Start == 7) System.out.println(" | x"); else if (Start == 8) System.out.println(" | x"); else if (Start == 9) System.out.println(" | x"); else if (Start >=-9) System.out.println("\n \n \n number has to be bewteen -9 og 9"); else if (Start <=9) System.out.println("\n \n \n number has to be bewteen -9 og 9"); } } else { for (int i = Start; Start>= end; Start--){ if (Start == -9) System.out.println("x |"); else if (Start == -8) System.out.println(" x |"); else if (Start == -7) System.out.println(" x |"); else if (Start == -6) System.out.println(" x |"); else if (Start == -5) System.out.println(" x |"); else if (Start == -4) System.out.println(" x |"); else if (Start == -3) System.out.println(" x |"); else if (Start == -2) System.out.println(" x |"); else if (Start == -1) System.out.println(" x |"); else if (Start == 0) System.out.println(" x"); else if (Start == 1) System.out.println(" | x"); else if (Start == 2) System.out.println(" | x"); else if (Start == 3) System.out.println(" | x"); else if (Start == 4) System.out.println(" | x"); else if (Start == 5) System.out.println(" | x"); else if (Start == 6) System.out.println(" | x"); else if (Start == 7) System.out.println(" | x"); else if (Start == 8) System.out.println(" | x"); else if (Start == 9) System.out.println(" | x"); else if (Start >=-9) System.out.println("\n \n \n number has to be bewteen -9 og 9"); else if (Start <=9) System.out.println("\n \n \n number has to be bewteen -9 og 9"); } } } public static void straight (int Start, int end){ if (Start < end){ for (int i = -9; i<= Start; i++){ System.out.print(" "); if (Start >=-9) System.out.print("\n \n \n number has to be bewteen -9 og 9"); else if (Start <=9) System.out.print("\n \n \n number has to be bewteen -9 og 9"); } for (int i = Start; Start<=end; Start++){ if (Start <= end) System.out.print(" x"); } } else { if (Start > end){ for (int i = -9; i<= end; i++){ System.out.print(" "); if (Start <=-9) System.out.print("\n \n \n number has to be bewteen -9 og 9"); else if (Start >=9) System.out.print("\n \n \n number has to be bewteen -9 og 9"); } for (int i = end; end<=Start; end++){ if (end <= Start) System.out.print(" x"); } } } } }
Hope someone can help me
and thanks in advance