Tech Support Guy banner
Not open for further replies.
1 - 2 of 2 Posts

41 Posts
Discussion Starter · #1 ·
I've been trying to make a java program, but i'm unable to make one section of it work the way I want it to

It's based on the following attachment. It is supposed to be a random name genrator for an assignment at Uni. It should take the first letter of your first name, the whole of your second name then give it a random number.

I have been able to make it do the last two tasks, however, I do not know how to make it take the first Char from the first name. I've made it take your whole first name because it is the only method that will work.
* @(#)
* StarWarsNameGenerator application
* @author
* @version 1.00 2008/3/12

import java.util.*;

public class StarWarsNameGenerator {
static Scanner wars = new Scanner(;

public static void main(String[] args)

// Prompt for User's Name
String letter1,letter2;

System.out.println("Please state your First Name");
letter1= wars.charAt(0);

System.out.println("Please state your Surname");;

//determine star wars name
Random generator = new Random();
int num1;
String Starwarsname;

num1 = generator.nextInt(99) + 10;

System.out.println("In a galaxy far, far away you are known as " + Starwarsname + " MAY THE FORCE be with you!");

I believe I need to enter something like "letter1=wars.charAt(0)" but it keeps on coming up with a variety of error messages.

Plese help me, or push me in the right direction.

1 - 2 of 2 Posts
Not open for further replies.