I just needed some assistance on formatting the output into a specific fashion. I satisfied all the requirements of the assignment, except the output.
I apologize for the bad format of this post, any suggestions and help is greatly appreciated.
I need the output to look like:
Mr. Random - $500
Mr. BobRandom - $250
etc-8 more times
(sum total of all dollars)
Heres my code:
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");
}
}
}