首页 > 解决方案 > Cannot get a very basic program to produce any output whatsoever

问题描述

I cannot get the Pearson MyProgrammingLab to produce any output from this code and several other programs like it. But the code works perfectly fine in other IDEs. Is there an error in the Scanner construction or anything else basic that I am overlooking?

I have exhausted so many solutions and still no luck. There is just simply no output when the program is checked, and cites it as a logic error.

Here is the code:

import java.util.Scanner;

class Area {
    public static void main (String[] args) {
        Scanner input = new Scanner (System.in);
        System.out.print("Enter the side: ");
        double s = input.nextDouble();
        double area = (6 * Math.pow(s, 2)) / (4 * Math.tan(Math.PI/6));
        System.out.println("The area of the hexagon is " + area);
        }
}

Any ideas?

EDIT: This is what the ouput when checked would display:

Given the following was entered from the keyboard:
5.5⏎

you displayed:

instead of:
Enter◦the◦side:The◦area◦of◦the◦hexagon◦is◦78.59⏎

标签: javaoutputjava.util.scanner

解决方案


推荐阅读