试图制作一张桌子,奇怪的制表符间距

时间:2019-02-02 21:28:08

标签: java tabular spacing graphing

我正在尝试编写一个程序,该程序根据用户提供的描述图形的参数来创建表。我只是在Java初学者,我刚刚起步的,所以如果我使用低效的方法则可能是其中的原因。我在编写代码时遇到的问题是,当我运行该程序时,似乎导致一个行的列间距与其他行的间距不同,这似乎是一个奇怪的情况。这是非常真气和我很想有一个解决的办法。再次,我是一名极端的初学者,并且仍然在写中型程序。 T

Scanner input = new Scanner(System.in);
Scanner input2 = new Scanner(System.in);
Scanner input3 = new Scanner(System.in);
Scanner input4 = new Scanner(System.in);
Scanner input5 = new Scanner(System.in);

    double xjumps;
    double yjumps;
    double start;
    double length;
    double intercept;

    System.out.printf("Please input the length of your table: ");
    length = input.nextDouble();

    System.out.printf("\n");
    System.out.printf("Please input the x-axis incrementation: ");
    xjumps = input2.nextDouble();

    System.out.printf("\n");
    System.out.printf("Please input the y-axis incrementation: ");
    yjumps = input3.nextDouble();

    System.out.printf("\n");
    System.out.printf("When do you want the table to start: ");
    start = input4.nextDouble();

    System.out.printf("\n");
    System.out.printf("Please input the y intercept: ");
    intercept = input5.nextDouble();


    double x = start;
    double y = (((start/xjumps) * yjumps) + intercept);

    System.out.printf("\n");
    System.out.println("X\t\t\tY");
    System.out.println(x + "\t\t" + y);
    for(double z = -1;z <= length;z++){
        x += xjumps;
        y += yjumps;
        System.out.println(x + "\t\t" + y);

    }

0 个答案:

没有答案