Needs help on adding a meaningful GUI to replace thecommand prompt input highlig
ID: 3618048 • Letter: N
Question
Needs help on adding a meaningful GUI to replace thecommand prompt input highlighted below. Can use any GUI containers.thx
public class Main
{
/**
* @param args the command linearguments
*/
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int max = 10;
ClassDataArrayarr,others; //reference to Array
others = newClassDataArray(max);
others.insertOther("Jane", "Wilson", 453.4);
others.insertOther("Google", "Walmart", 2343.5);
others.insertOther("Amazon", "Ebay", 32000.0);
others.displayOther();
System.out.println("Enter one of the abovesalary");
double dou =input.nextDouble();
boolean trueOrFal = others.deleteOther(dou);
System.out.println(" Deleting " +dou);
if(trueOrFal == true)
others.displayOther();
else
System.out.println("No such salary in our database");
}
}
class Chray
{
private String stt;
private String lstt;
private double dr;
private static int count =0;
public Chray()
{
count +=1;
}
public Chray(String x, Stringz, double y)
{
stt = x;
lstt = z;
dr = y;
}
public void est()
{
System.out.println(" The name is " + stt+" " +lstt +", salary is"+dr);
}
public double getAmt()
{
return(dr);
}
}
class ClassDataArray
{
private Chray b[];
private int nOther;
public ClassDataArray(int oMax)
{
b = newChray[oMax];
nOther = 0;
}
public void insertOther(String last,String first, double sal) //put person intarray
{
b[nOther] = newChray(last, first, sal);
nOther++;
}
public void displayOther()
{
for(int i=0;i<nOther;i++)
b[i].est();
}
public boolean deleteOther(doublesearchAmt)
{
int j;
for(j=0;j<nOther; j++)
if( b[j].getAmt() == (searchAmt))
break;
if(j ==nOther)
return false;
else
{
for(int k=j; k<nOther; k++)
b[k] = b[k+1];
nOther--;
return true;
}
}
}
Explanation / Answer
System.out.println("Enter one of the above salary");double dou =input.nextDouble();
Replace that with JOptionPane.
String enter = JOptionPane.showInputDialog("Enter one of theabove salary"); double dou =Double.parseDouble(enter);
Don't forget to import the below.
import javax.swing.JOptionPane;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.