在java中使用Int

时间:2013-11-16 12:04:33

标签: java swing java-ee joptionpane

如何显示一个对话框,要求用户输入学生人数......(突出显示的部分)![在此处输入图像说明] [1]

    JOptionPane.showMessageDialog(null, "Welcome");
    JOptionPane.showMessageDialog(null, "Students mark Input Project");
    JOptionPane.showMessageDialog(null, "In this program the user is going to enter the students name, class and marks.Then the program is going to output several information about each student.");
    JOptionPane.showMessageDialog(null, "Class Information must be entered as the name of the class, the subject and the number of students");
    String nameofclass = JOptionPane.showInputDialog("Enter the name of the class");
    String nameofsubject = JOptionPane.showInputDialog("Enter the subject"); 
    int numberofstudents =Integer.parseInt("Enter the number of students");
    JOptionPane.showMessageDialog(null,"Class Students Information");
    JOptionPane.showMessageDialog(null,"You must enter the name, surname and " + nameofsubject + " marks for each and every student in class "+ nameofclass);
    StLuciaClassrooms theclass =new StLuciaClassrooms(nameofclass, numberofstudents);
    theclass.enterInformation(numberofstudents);//

1 个答案:

答案 0 :(得分:1)

试试这个

 int numberofstudents =Integer.parseInt(JOptionPane.showInputDialog("Enter the number of students"));