Created
February 7, 2012 22:11
-
-
Save mahmoudhossam/1762451 to your computer and use it in GitHub Desktop.
something I don't even know
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import javax.swing.*; | |
public class Test{ | |
enum concentrations {MATH, SCIENCE, ENGLISH, WEB}; | |
public static void main(String[] args) { | |
ArrayList<String> names = new ArrayList<String>(); //stores student's names | |
int[] stuConc = new int[500]; //stores student's concentration pick | |
int[] concentCount = new int[4]; | |
input(names, stuConc); | |
count(stuConc, concentCount); | |
output(names, concentCount, concentrations); | |
} | |
private static void input(String[] stuNames, int[] stuPick) | |
{ | |
int i = 0; | |
do | |
{ | |
stuNames[i] = JOptionPane.showInputDialog("Student's name: "); | |
stuPick[i] = Integer.parseInt(JOptionPane.showInputDialog("Your concentration: \n1. DTP\n2. INFS\n3. NTEL\n4. WDM")); | |
i++; | |
} | |
while(JOptionPane.showConfirmDialog(null, "Another student?")==JOptionPane.YES_OPTION); | |
} | |
private static void output(ArrayList<String> names, int[] concentCount, String[] concent) | |
{ | |
ArrayList<String> nameList= new ArrayList<String>(); | |
ArrayList<String> concentCountList = new ArrayList<String>(); | |
for(int i =0; i < names.length; i++) | |
{ | |
nameList.add(names[i]); | |
} | |
for(int i=0; i<concent.length; i++) | |
{ | |
concentCountList.add(concent[i]+ ": "+ concentCount[i]); | |
} | |
JOptionPane.showMessageDialog(null, nameList); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment