Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

273
Views
Nombre de índice de Java
String nameOfTools = ""; for( int index = 0; index < userToolType; index++ ) { nameOfTools = JOptionPane.showInputDialog( "Please enter name of tool " + ( index + 1 ) ); //check blank if ( nameOfTools.equalsIgnoreCase("") ) { JOptionPane.showMessageDialog(null, "You entered blank"); System.exit( 0 ); } } //Ask the number to buy for each tool String numberOfTools; double toolsNumber = 0; String amountOfTools; double moneyForTools; double totalMoneyToPay = 0; for ( int index = 0; index < userToolType; index++ ) { numberOfTools = JOptionPane.showInputDialog( "How many you need to buy " + ( index + 1 ) ); toolsNumber = Double.parseDouble( numberOfTools );

Quiero que el cuadro de diálogo muestre "Cuántos necesita (el nombre de una herramienta)", no el número de índice, ¿cómo puedo hacer esto?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Luego debe crear un ArrayList<String> para almacenar los nombres de las herramientas, algo como esto:

 ArrayList<String> toolsNames = new ArrayList<String>(); // to take all names for( int index = 0; index < userToolType; index++ ){ String input = JOptionPane.showInputDialog( "Please enter name of tool " + ( index + 1 ) ); if ( input.equals("") ){ //check blank JOptionPane.showMessageDialog(null, "You entered blank"); System.exit( 0 ); } toolsNames.add(input); // if it's not blank } //Ask the number to buy for each tool String numberOfTools; double toolsNumber = 0; String amountOfTools; double moneyForTools; double totalMoneyToPay = 0; for ( int index = 0; index < userToolType; index++ ){ numberOfTools = JOptionPane.showInputDialog( "How many you need to buy from " + toolsNames.get(index)); toolsNumber = Double.parseDouble( numberOfTools ); }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!