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 4 of 4

Thread: Generating random letters and numbers together

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Generating random letters and numbers together

    Hi, I've just started studying Java and got stuck in this exercise so can anyone help me to solve it. I can only generate letters or numbers and don't know how to make it together.

    Generate 3 charater + 3 numbers:

    -the first character is randomly generated from the alphabets with odd ordering in the alphabet list (A, C, E, …, Y)

    -the second character is randomly generated from the alphabets with even ordering in the alphabet list (B, D, F, …, Z)

    -the third character is randomly generated from alphabet list (A to Z)

    -each of the three digits is random generated from 1 to 9.

    Use the random method from the Maths Class.

    Thank you


  2. #2
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    494
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: Generating random letters and numbers together

    No, we won't do your homework for you. But if you can post what you've got so far and aska specific question, that might get you some useful responses.

    db

  3. #3
    Junior Member
    Join Date
    Mar 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Generating random letters and numbers together

    alright, I've done that but in another exercise I can't run it completely so can you help me to check what's wrong with it ? Thanks.

    Write a JAVA program that calculates the surface area of a cylinder, C= 2( π r2) + 2 π r h, where r is the radius and h is the height of the cylinder. Allow the user to enter in a radius and a height. Format the output to three decimal places. Use the constant PI and the method pow() from the Math class.

    This is what I've done:

    /**
     * @(#)Ex5.java
     *
     *
     * @author
     * @version 1.00 2010/3/18
     */
     
    import Java.util Scanner;
    public class Ex5 {
     
        public static void main (String[] args)
        {
        	Scanner input.new Scanner(System.in);
        	double radius,height,area;
        	System.out.print("Please enter the radius of the Cylinder");
        	radius = input.nextDouble();
        	System.out.print("Please enter the height of the Cylinder");
        	height = input.nextDouble();
        	area = (height*2+Match+radius)+2*Math.PI+Math.POW(radius,2);
        	System.out.println("The surface of the cylinder" + area);
     
        }
     
     
    }
    Last edited by Freaky Chris; March 19th, 2010 at 06:33 AM.

  4. #4
    Member Faz's Avatar
    Join Date
    Mar 2010
    Posts
    97
    Thanks
    5
    Thanked 14 Times in 14 Posts

    Default Re: Generating random letters and numbers together

    Well your fomula is wrong. Why don't you make it like it is written in the question and see if that works? As for formatting to 3 decimal places check this out.

    http://www.javaprogrammingforums.com...al-places.html

    Actually your formula is very wrong just so you know π r(squared) is pi * radius(squared) not pi+radius squared your better off googling surface of cylinder or something.
    Last edited by Faz; March 19th, 2010 at 04:13 AM.

Similar Threads

  1. Generation of random number using random class
    By JavaPF in forum Java SE API Tutorials
    Replies: 1
    Last Post: December 7th, 2011, 05:46 PM
  2. help me .. about creating random numbers
    By soldier in forum Java Theory & Questions
    Replies: 2
    Last Post: December 20th, 2009, 08:24 PM
  3. How to remove letters
    By noobish in forum Java Theory & Questions
    Replies: 13
    Last Post: October 3rd, 2009, 10:36 PM
  4. Random numbers
    By Pooja Deshpande in forum Java SE APIs
    Replies: 8
    Last Post: June 5th, 2009, 04:36 AM
  5. Programming partner that can earn revenue
    By Jay in forum Project Collaboration
    Replies: 0
    Last Post: May 25th, 2009, 02:33 PM