这是一个简单的计算器程序.在我的程序继续"添加"输入的两个参数之前,我只需要检查我的数组并防止其中包含任何字母.输入来自命令行,例如java adder 1 2
public class Adder {
public static void main(String[] args) {
//Array to hold the two inputted numbers
float[] num = new float[2];
//Sum of the array [2] will be stored in answer
float answer = 0;
/*
some how need to check the type of agruments entered...
*/
//If more than two agruments are entered, the error message will be shown
if (args.length > 2 || args.length < 2){
System.out.println("ERROR: enter only two numbers not …Run Code Online (Sandbox Code Playgroud)