我只是需要一些帮助将输出格式化为特定的方式。除了输出外,我满足了作业的所有要求。将数组的输出格式化为列
我很抱歉为这篇文章的坏格式,任何建议和帮助,非常感谢。
我需要的输出看起来像:
随机先生 - $ 500强
BobRandom先生 - $ 250
等-8
(合计的所有美元)多次
继承人我的代码:
import javax.swing.JOptionPane;
import java.util.Arrays;
public class PeerTutors {
public static void main(String[] args) {
String[] myNameArray = new String[2];
String[] myGradeArray = new String[2];
double[] myStudentArray = new double[2];
double[] stipend = new double[2];
int sum = 0;
for (int i = 0; i < 2; i++) {
myNameArray[i] = (JOptionPane
.showInputDialog(null,
"Enter the Peer Tutor name, last name then followed by the first name."));
}
Arrays.sort(myNameArray, String.CASE_INSENSITIVE_ORDER);
JOptionPane.showMessageDialog(null, "The Peer Tutors Names are :"
+ Arrays.toString(myNameArray));
for (int a = 0; a < 2; a++) {
myGradeArray[a] = JOptionPane.showInputDialog(null,
"Please enter the highest degree earned for: "
+ myNameArray[a]);
}
JOptionPane.showMessageDialog(null, "The Peer Tutors Names are :"
+ Arrays.toString(myNameArray) + Arrays.toString(myGradeArray));
for (int b = 0; b < 2; b++) {
myStudentArray[b] = Double.parseDouble(JOptionPane.showInputDialog(
null, "Please enter the number of students"
+ myNameArray[b] + " has assisted"));
}
JOptionPane.showMessageDialog(null,
"The Peer Tutors Report: " + Arrays.toString(myNameArray)
+ "with" + Arrays.toString(myStudentArray)
+ " of children tutoring");
for (int c = 0; c < 2; c++) {
if (myGradeArray[c].equals("BS")) {
stipend[c] = 9.5 * myStudentArray[c];
} else if (myGradeArray[c].equals("MS")) {
stipend[c] = 15 * myStudentArray[c];
} else {
stipend[c] = 20 * myStudentArray[c];
}
}
for (double d : stipend) {
sum += d;
}
for (int d = 0; d < 2; d++) {
JOptionPane.showMessageDialog(null, myNameArray[d] + "-"
+ stipend[d] + "\n");
}
}
}
你能发布你的代码当前输出吗? – asifrc 2013-04-11 04:12:31