Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: I need help adding a ratio into a String

  1. #1
    Junior Member
    Join Date
    Sep 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I need help adding a ratio into a String

    How do i add a ratio into this program. it needs to find the ratio from lowercase to uppercase.



    import java.util.Scanner;

    public class Strings
    {
    public static void main(String[] args)
    {

    // Set up a Scanner object for keyboard input.
    Scanner in = new Scanner(System.in);



    // Set up Strings for lower and upper case letters.
    String Upper = "";

    String Lower = "";

    // Print a line of text.
    System.out.print("Please give a string: ");

    // Set up String variable to hold keyboard input.
    String x = in.next();
    int z = x.length();

    for(int y = 0; y < z; y++)

    if(Character.isUpperCase(x.charAt(y)))
    {
    char w = x.charAt(y);
    Upper = Upper + w + " ";
    }
    else if(Character.isLowerCase(x.charAt(y)))
    {
    char w = x.charAt(y);
    Lower = Lower + w + " ";
    }



    {System.out.println("\nThe Lowercase characters are: " + Lower);}
    {System.out.println("\nThe Uppercase characters are: " + Upper);}

    }
    }


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: I need help adding a ratio into a String

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Please post your code correctly using code or highlight tags per the above link.

Similar Threads

  1. Gallery view and image aspect ratio.
    By ddscs in forum Android Development
    Replies: 1
    Last Post: April 20th, 2013, 01:35 PM
  2. [SOLVED] Problems with my Portholes... (String splitting and adding to lines)
    By Adzox in forum What's Wrong With My Code?
    Replies: 7
    Last Post: December 25th, 2012, 03:02 PM
  3. Adding to a string array?
    By BITmixit in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 17th, 2011, 10:12 PM
  4. Replies: 3
    Last Post: November 20th, 2011, 02:33 PM
  5. adding multiple ints into a string
    By straw in forum Java Theory & Questions
    Replies: 1
    Last Post: March 18th, 2010, 06:02 PM