Results 1 to 8 of 8
  1. #1
    simsli is offline Member
    Join Date
    Feb 2016
    Posts
    5
    Rep Power
    0

    Default Can you hep me with my code!

    Hello, guys! I need help....I am a new with java but is little hard to me to do this... i must to do a code to show me a min and max number and between them! Example 1,3,4,5,6,7,8,9,10.... min = 1 max=10 and between them=3,4,5,6,7,8,9.. But is must to be with string not with intArray... Can you help me pls! Thank you!

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,422
    Blog Entries
    7
    Rep Power
    28

    Default Re: Can you hep me with my code!

    Why can't you use a numerical array? Because the assignment text says so?

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  3. #3
    simsli is offline Member
    Join Date
    Feb 2016
    Posts
    5
    Rep Power
    0

    Default Re: Can you hep me with my code!

    i'm sorry for the another post... i'm new in this site and i didn't know how i post the problem.... Can you help me with this java code... the answer is a 1. Write a function that reads an array of strings (each string contains one or several numbers) and returns the smallest and largest number and all numbers between them.
    Example:
    station8, 2ndExit, block9a, floor5
    Results:
    Min: 2
    Max: 9
    InBetween: 3, 4, 5, 6, 7, 8

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,007
    Rep Power
    34

    Default Re: Can you hep me with my code!

    what have you tried? Do you have any specific questions about any problems you are having?

    Be sure to wrap any posted code in code tags.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    simsli is offline Member
    Join Date
    Feb 2016
    Posts
    5
    Rep Power
    0

    Default Re: Can you hep me with my code!

    all i done is this but i'm sure is not a true....

    public class ArrayElements {
    private static Scanner scanner;

    public static void main(String[] args) {



    String[] arr = new String[4];

    arr[0 ]= "floor5";
    arr[1] = "floor12";
    arr[2] = "floor8";
    arr[3] = "floor34";

    String line = scanner.nextLine();

    int[] intArray = new int[stringArray.length];

    for(int i = 0;i < arr.length;i++){
    numbers[i] = Integer.parseInt(arr[i]);
    }
    System.out.println("arr" + arr);

    }

    }
    Can you write the code for me.... is more important to me to do this.... Can you help me?

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,422
    Blog Entries
    7
    Rep Power
    28

    Default Re: Can you hep me with my code!

    Trying to parse a String, say, "floor34" as if it represents an int, is never going to work ...

    kind regards,

    Jos

    ps. and please stop opening new threads for this single problem.
    Build a wall around Donald Trump; I'll pay for it.

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,007
    Rep Power
    34

    Default Re: Can you hep me with my code!

    If numeric digits can be embedded in a String containing any characters, you will need to look at the characters one by one and extract the numeric ones to a separate String that can then be converted to an int value. There might be a Regular Expression to do that, but I don't know RE good enough to help.

    Be sure to wrap your code with code tags:
    [code]
    **YOUR CODE GOES HERE**
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my response, don't ignore it, ask a question.

  8. #8
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: Can you hep me with my code!

    Clearly you wrote this code down without bothering to compile it. It is full of errors.
    At least make an effort of getting something to compile and run.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Posting code to forum : Code to code tags
    By rushtojess in forum Suggestions & Feedback
    Replies: 2
    Last Post: 04-21-2015, 08:16 PM
  2. Replies: 1
    Last Post: 03-25-2012, 03:40 AM
  3. Replies: 16
    Last Post: 01-31-2012, 08:36 PM
  4. Replies: 0
    Last Post: 08-07-2011, 08:32 PM
  5. Replies: 1
    Last Post: 04-26-2007, 03:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •