double + double = String?(double + double = String?)
我有一个问题,输出应该是双重的,但它是字符串我试图添加两个double值,但它将它作为一个字符串。 我正在使用eclipse。 目前该程序正在编译和运行。 如果有人有片刻我会很感激。干杯。 这是源代码。
import java.util.Scanner; public class FutureInvestment { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter investment amount: "); double investmentAmount = input.nextDouble(); System.out.println("Enter monthly interest rate: "); double monthlyInterestRate = input.nextDouble(); System.out.println("Enter number of years: "); int numberOfYears = input.nextInt(); double futureInterestValue = investmentAmount * ( Math.pow((1 + monthlyInterestRate), numberOfYears * 12)); System.out.println("Accumulated value is: " + futureInterestValue + investmentAmount); } }
I have a problem the output is supposed to be double but instead it is string I am trying to add two double values but it is giving it as a string. I am using eclipse. Currently the program is compiling and running. If anyone have a moment I would appreciate it.Cheers guys. Here is the source code.
import java.util.Scanner; public class FutureInvestment { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter investment amount: "); double investmentAmount = input.nextDouble(); System.out.println("Enter monthly interest rate: "); double monthlyInterestRate = input.nextDouble(); System.out.println("Enter number of years: "); int numberOfYears = input.nextInt(); double futureInterestValue = investmentAmount * ( Math.pow((1 + monthlyInterestRate), numberOfYears * 12)); System.out.println("Accumulated value is: " + futureInterestValue + investmentAmount); } }
原文:https://stackoverflow.com/questions/9454509
最满意答案
执行命令时,路径中的目录将按照它们在变量中出现的顺序进行搜索,直到找到您键入的命令。
在这里看到第一个答案: https : //superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them
When you execute a command, the directories in path are searched in the order they appear in the variable until the command you typed is found.
See the first answer here: https://superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them
相关问答
更多-
您必须出现问题或机器出现环境问题。 添加用户PATH环境变量确实会导致它被合并到新进程的环境中。 更新:也许这个来自MSDN主题的关于环境变量的评论可能是相关的: 发现在Windows Server 2003上,一旦系统PATH传递了1920个字符,用户PATH环境变量就不再与它合并来设置进程PATH环境变量,尽管系统完整路径(即使更大)将包含在进程PATH变量。 You must be getting something wrong, or have environmental problems with ...
-
当你用双引号将它写出来时,你不需要用\ export PATH=$PATH:"/cygdrive/C/Program Files/Java/jdk1.6.0_23/bin/" 当然这也有效: export PATH=$PATH:/cygdrive/C/Program\ Files/Java/jdk1.6.0_23/bin/ as you write the it with double-quotes, you don't need to escape spaces with \ export PATH= ...
-
Path和PATH环境变量(Path and PATH environment vars)[2023-09-16]
这是正常的,无需修复。 在Windows中,环境变量名称不区分大小写。 如果你这样做,你可以看到它: echo %PATH% 在cmd提示符下。 它将显示两个值的组合。 It's normal, no need to fix. In Windows, environment variable names are case-insensitive. You can see it if you do: echo %PATH% in cmd prompt. It will display the combin ... -
执行命令时,路径中的目录将按照它们在变量中出现的顺序进行搜索,直到找到您键入的命令。 在这里看到第一个答案: https : //superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them When you execute a command, the directories in path are searched in the order they a ...
-
在Admin Cmd提示符中尝试此操作,如果有任何错误,请告诉我: @echo off setLocal EnableDelayedExpansion set "RPath=C:\R-3.2.5\bin\x64" set "envPath=%PATH%" & set "Separator=" if not "%envPath:~-1%" == ";" set "Separator=;" if "!envPath:%RPath%=!"=="%envPath%" ( ...
-
PATH系统变量有助于立即找到您需要的可执行文件,指定一组可执行程序所在的目录。 或者你必须指定他们所在的路径。 因此,您不必在系统中的每个可执行文件目录中添加PATH ,但可以在相同情况下提供帮助,例如,可执行文件经常由用户使用或由其他可执行文件程序使用。 JDK有一个由开发人员,IDE和其他工具(Maven,Ant,Ivy等)经常使用的可执行程序(例如java , javac , jar , jstat等)的一系列内容,所以它是一个最好的练习向PATH添加JDK可执行文件所在的目录。 谈到环境变量,Ja ...
-
它的工作方式与Java相同。 例如,在使用log4cxx::xml::DOMConfigurator::configure configure读取的XML配置中,包含 ,环境变量LOG_DIR将正确取代。 使用log4cxx 0.9.7在Linux / Ubuntu 12.01上测试。 另请参阅我的问题和答案: https : //mail-archives.apache.org/mod_mbox/loggi ...
-
RUN命令仅在容器的文件系统上运行,而不是在主机的文件系统上运行。 您必须将文件从本地文件系统复制到容器的文件系统: FROM jboss/wildfly COPY src /src RUN javac /src/Hello.java 许多开发人员发现他们想要将他们的构建容器与运行容器分开。 运行软件的容器对其环境的要求通常比构建容器要少得多(例如,没有安装JDK,只有JRE)。 为此你的构建容器将是: FROM openjdk:8 COPY src /src RUN javac /src/Hello.j ...
-
无法设置javac的路径(can't set path for javac)[2021-11-08]
只需要设置临时路径集路径= C:\ Program Files \ Java \ jdk1.7.0_45; 或将您的环境变量路径更改为 变量名=%path%变量值:\ Program Files \ Java \ jdk1.7.0_45; 然后打开cmd并运行javac命令进行检查 Okay, so I have solved my problem: In Environment Variables, the "Variable Name" must be: PATH The Variable value ... -
您的可执行文件名是pycharm.sh ,而不是pycharm 。 尝试输入,而不是。 您也可以尝试使用which pycharm.sh尝试使用PATH环境变量查找给定的命令,以查看您的配置是否有效。 Your executable filename is pycharm.sh, not pycharm. Try typing that instead. You could also try which pycharm.sh, which attempts to locate given command u ...