0
我想要替换数组中的对象,如果用户输入字母E/e。例如,数组可以包含2个对象,数组中的第一个对象用户输入一个3,用户现在输入一个5e,他们新的数组对象[0]变成新的用户输入5.这是我的代码到目前为止:尝试比较一个数组项目与useres输入
import java.text.*;
import java.io.*;
public class Lab1a {
public static void main (String argv []) throws IOException {
BufferedReader stdin = new BufferedReader (new InputStreamReader (System.in));
NumberFormat nf = NumberFormat.getNumberInstance();
nf.setMaximumFractionDigits (2);
nf.setMinimumFractionDigits (2);
String inputValue;
double [] doubleValues = new double [1];
char char1, char2, char3;
inputValue = stdin.readLine();
String [] Values2 = inputValue.split ("\\s+");
for (int i = 0; i < Values2.length; ++i)
doubleValues [i] = Double.parseDouble (Values2[i]);
double old = doubleValues[0];
double newNum = doubleValues[1];
//Line 3: 3 characters separated by spaces
inputValue = stdin.readLine();
String [] Values3 = inputValue.split ("\\s+");
for (int i = 0; i < Values3.length; ++i);
char1 = Values3[0].charAt(0);
char2 = Values3[1].charAt(0);
char3 = Values3[2].charAt(0);
if (inputValues == 'double' + "e") {
System.out.println(old);
}
}
请包括一个具体的问题。 – Spencer4134
你最后一个for循环只是循环而不做任何事情。循环后摆脱';'。 –
你的问题不是很清楚。用样本输入输出解释 – thedarkpassenger