java - 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⏎
解决方案
推荐阅读
- python - Selenium 屏幕截图在 python 中保存到数据库
- c# - 直接使用返回值与局部变量有何不同
- java - Tomcat 9 jndi:协议 MalformedURLException:未知协议:jndi
- java - Comparator.comparing 中的多项检查
- html - 使用严格排序的 grid/flex 填充垂直空白
- bouncycastle - 尝试将 Bouncy Castle 生成的密钥放入 AndroidKeyStore 时出现“不支持的密钥算法:ECDSA”
- node.js - Express:使用声明合并扩展 request.query 会引发 TypeScript 错误
- assembly - 错误的库在手动生成的 PE 64 位可执行文件中加载了错误的函数
- php - 服务器端处理问题 Class SSP not found
- netty - gPRC java:'流的窗口大小溢出:0'