java - Grading system with JOptionPane and FileWriter -


i'm making simple grading system enter how many subjects calculate, finds lowest, highest, sum, , average grades gui.

my question how enter user without joptionpane popup?

here's code:

import javax.swing.*; import java.io.*; class aaa {     public static void main(string args[])throws ioexception     {         string name = joptionpane.showinputdialog("enter name");         int select = integer.parseint(joptionpane.showinputdialog("enter how grades calculate"));         double grades[]=new double[select] , high = double.min_value ,low = double.max_value,sum=0;             for(int a=0 ; a<grades.length ; a++)             {                 grades[a]=double.parsedouble(joptionpane.showinputdialog("grades no. "+(a+1)+":\n"));                 sum+=grades[a];                 if(grades[a]>high)                 {                     high=grades[a];                 }                 if(grades[a]<low)                 {                     low=grades[a];                 }             }             double ave=sum/select;         int choice = integer.parseint(joptionpane.showinputdialog("do want save file?\n1 yes\n2 no"));         switch(choice)         {             case 1:                 string fname = joptionpane.showinputdialog("enter output filename:");                 filewriter writer = new filewriter(fname);                 writer.write("name:\t"+name.touppercase()+"\nsum:"+sum+"\naverage:"+ave+"\nhighest:"+high+"\nlowest:"+low);                 writer.close();                 break;             case 2:                 joptionpane.showmessagedialog(null,string.format("name: %s\nsum:%.2f\naverage:%.2f\nhighest:%.2f\nlowest:%.2f",name.touppercase(),sum,ave,high,low));                 break;         default:             joptionpane.showmessagedialog(null,"invalid!",":(",joptionpane.error_message);         }     } } 


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -