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

# Thread: Generating random letters and numbers together

1. ## 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. ## 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. ## 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);
System.out.print("Please enter the height of the Cylinder");
height = input.nextDouble();
System.out.println("The surface of the cylinder" + area);

}

}```

4. ## 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.