Programming challenge description: In this challenge, you're given a string containing jumbled letters from several concatenated words. Each word is a numeral from zero to nine. Each numeral may be used multiple times in the jumbled string. Write a program that returns integers corresponding to the numerals used to form the jumbled string. Integers must be sorted in ascending order. For example, reuonnoinfe are shuffled letters of the strings one four nine. Your program's output should be 149.

Respuesta :

Following are the program to the given question:

import java.util.*;//import package

public class Main//defining main method

{

public static void main (String[] axv)//defining main method

{

String nums[] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};//defining an arrayof string

int i,j;

Scanner obxc = new Scanner(System.in);//creating Scanner class object to input value

System.out.print("Enter a string formed jumbled letters of numerals: ");//print message

String w = obxc.next();//defining a String variable that input String value

for(i=0; i<nums.length; i++)//defining a loop to count input String length

{

String sa = nums[i];//defining a string variable to hold array value

boolean f = true;//defining a boolean variable

for(j=0; j<sa.length(); j++)//defining a for loop that convets value into integer

{

char cx = sa.charAt(j);//defining char variable that hold value

if(w.indexOf(cx)==-1)//defining if block to check indexOf value

{

f = false;//use boolean variable that hold boolean value

break;//using break keyword

}

}

if(f) //use if to check boolean value

System.out.print (i);//use print method that print i value

}

System.out.println();//use print method for beak line

}

}

Output:

Enter a string formed jumbled letters of numerals: onefournine

149

Explanation of code:

  • Import package.
  • Defining the main class and also define the main method in it.
  • Inside the main method defining a string of array "nums" that holds sting value and two integer variables "i,j" is defined.
  • In the next step, a scanner class object is declared that inputs the value.
  • After input, a value a for loop is defined that uses a string variable that holds an array value and uses another loop that converts string value into a numeric value.

Learn more:

brainly.com/question/15126397