Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Develop an interactive java program using dialogs for both input and output, to

ID: 3749756 • Letter: D

Question

Develop an interactive java program using dialogs for both input and output, to Prompts the user to enter the:

Employee first name

Employee last name

GS level

Step level

New Employees are hired at a given grade at step level 1. Employees are automatically moved up by 3 step every year. If an employee is at the last step of a grade she/he is moved to the next grade level step 6 (employee at grade 12 step 10 is moved to grade 13 step 6). Report all information employee, current salary and projected salary for year 2019.

Input Please Enter Employee First Name OK Cancel Input ? Please Enter Employee Last Name Input Please Grade Level nteger 1-15 OK Cancel Input Please Step Level Onteger 1.10 Output First Name Last Name:Oiney Current Step Level:10 Future Grade Scale:13 Future Step Level:6 Future Salary: 1165620

Explanation / Answer

Step1:

Create a main class where need to call data source and logic to calculate future grade and Scale. (app is package created for this , hasmap to store data and JOptionPane for GUI)

package app;
import java.util.HashMap;
import java.util.List;

import javax.swing.JOptionPane;

public class EmpGradeScaleMain{

   public static void main(String[] args) {
       try
       {

       //input values
       Object FirstName = JOptionPane.showInputDialog(null,"Please Enter Employee First Name")   ;
        Object LastName = JOptionPane.showInputDialog(null,"Please Enter Employe Last Name")   ;
        Object gradeLevel = JOptionPane.showInputDialog(null,"Please Grade Level Integer 1-15")   ;
//check for wrong input   

   int igradelevel = Integer.parseInt(gradeLevel.toString());
       if (igradelevel>0 && igradelevel<16)
       {
      
       Object stepLevel = JOptionPane.showInputDialog(null,"Please Step Level Integer 1-10")   ;
       //check for wrong input
       int isteplevel = Integer.parseInt(stepLevel.toString());
       if (isteplevel>0 && isteplevel<11)
       {
      
       System.out.println(" Employee Last Name "+ gradeLevel);

      //read input data source i have taken text file with '|" speration.
       ReadingFile readfile = new ReadingFile();
       HashMap<String, List<String> > TData = readfile.creatingTableStatus();
       String key = "GS-"+gradeLevel.toString();
       List<String> rowData = TData.get(key);
       StringBuffer msg = new StringBuffer();

//calculate value according to logic
       if(rowData.size()>0)
       {
           String fgradeLevel = null , fstepLevel = null,fSalary = null;
           if (isteplevel ==10)
               {
               if (igradelevel!=15)
                  igradelevel = igradelevel +1 ;
                  isteplevel =6;
               }
              fSalary = rowData.get(isteplevel);
              fgradeLevel = Integer.toString(igradelevel);
              fstepLevel= Integer.toString(isteplevel);
           msg.append("_____________________________________________ ");
           msg.append(" First Name :"+ FirstName+" ");
           msg.append(" Last Name :"+ LastName+" ");
           msg.append("______________________________________________ ");
           msg.append(" Current Grade Scale :"+ gradeLevel+" ");
           msg.append(" Current Step Level :"+ stepLevel+" ");
           msg.append("_______________________________________________ ");
           msg.append(" Future Grade Scale :"+ fgradeLevel+" ");
           msg.append(" Future Step Level :"+ fstepLevel+" ");
           msg.append(" Future Salary :"+ fSalary+" ");
           msg.append("_______________________________________________ ");
          
       }
       else
           msg.append(" you have entried invalid grade");
          JOptionPane.showMessageDialog(null,msg,"Message", JOptionPane.INFORMATION_MESSAGE)   ;
      
       }
       else
       {
           JOptionPane.showMessageDialog(null,"Step entred is not correct","Message", JOptionPane.ERROR_MESSAGE)   ;
       }
          
       }}
       catch (Exception ex)
       {
          
       }
   }
  
}

Step 2: create file ReadFile.java and change file full path in following line FileReader("e:\cheggQ.txt"));

//class to read data.

//file name :ReadingFile.java

package app;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class ReadingFile {

  
   public HashMap<String, List<String> > creatingTableStatus ()
   {
       HashMap<String, List<String> > mappingData = new HashMap<>();
       try {

//file path is hardcoded you need to change here according to created text file.
            BufferedReader in = new BufferedReader(new FileReader("e:\cheggQ.txt"));
            String str;
            while ((str = in.readLine()) != null)
            {
               List<String>rowData = processString(str);
               String firstkey = rowData.get(0);
               mappingData.put(firstkey, rowData);
            }
            in.close();
       } catch (IOException e) {
       }
       return mappingData;
   }
  
   public List<String> substringFromLine ( String fline)
   {
       List<String>rowData = new ArrayList<>();
       while (fline.indexOf('|')>0)
       {
           String data = fline.substring(0, fline.indexOf('|'));
           //System.out.println("data "+ data);
           String remainingString = fline.substring(fline.indexOf('|')+1, fline.length());
           if(remainingString.indexOf('|')<0)
           {
               rowData.add(remainingString);
           }
               rowData.add(data);
           //System.out.println("remaining String "+ remainingString);
           fline = remainingString;
       }
       return rowData;
              
   }
   public List<String> processString(String fileline)
   {
       //dividing string into other parts and then working on that .
      
       //GS Grade ! Step 1| Step 2| Step 3| Step 4| Step 5|Step 6 | Step 7
       //GS-1 | $24821
       List<String>rowData   = substringFromLine(fileline);
       System.out.println("---------------------");
      
       for ( String data : rowData)
       {
           System.out.println("data "+ data);
       }
       return rowData;
   }  
}

Step 3: create text file in follwoing format

//Input File Data

//filename : cheggQ.txt full path ="e:\cheggQ.txt"

//Enter all data in this file accordin to this format and change file path on ReadingFile.java

GS Grade|Step 1|Step2|Step 3|Step4|Step 5|Step 6|Step 7|Step 8|Step 9|Step 10
GS-1|$24,821|$25,652|$26,478|$27,298|$28,124|$28,606|$29,421|$30,246|$30,278|$31,053
GS-2|$27,907|$28,572|$29,495|$30,278|$30,621|$31,522|$32,423|$33,325|$34,226|$35,127
GS-3|$30,449|$31,464|$32,479|$33,494|$33,508|$35,523|$36,538|$37,553|$38,567|$39,582
GS-4|$34,183|$35,322|$36,461|$37,600|$38,739|$39,878|$41,017|$42,156|$43,295|$44,434
GS-5|$38,245|$39,520|$40,795|$42,070|$43,345|$44,620|$65,895|$47,170|$48,445|$49,721
GS-6|$42,630|$44,051|$45,471|$46,892|$48,312|$49,732|$51,153|$52,573|$53,994|$55,414
GS-7|$47,374|$48,953|$50,532|$52,111|$53,690|$55,269|$56,848|$58,427|$60,006|$61,584
GS-8|$52,465|$54,214|$55,964|$57,713|$59,462|$61,212|$62,961|$64,711|$66,460|$68,209
GS-9|$57,948|$59,880|$61,812|$63,743|$65,675|$67,607|$69,539|$71,470|$73,402|$75,334
GS-10|$63,815|$65,942|$68,069|$70,197|$72,324|$74,451|$76,579|$78,706|$80,883|$82,960
GS-11|$70,111|$72,448|$74,786|$77,123|$79,460|$81,798|$84,135|$86,472|$88,810|$91,147
GS-12|$84,035|$86,836|$89,637|$92,438|$95,239|$98,040|$100,842|$103,643|$106,444|$109,245
GS-13|$99,927|$103,258|$106,589|$109,920|$113,251|$116,582|$119,913|$123,244|$126,575|$129,906
GS-14|$118,085|$122,021|$125,957|$129,893|$133,829|$137,765|$141,702|$145,638|$149,574|$153,510
GS-15|$138,899|$143,529|$148,159|$152,789|$157,418|$162,048|$164,200|$164,200|$164,200|$164,200

Step 5: Run as java program EmpGradeScaleMain.java

As main is inside this only.