Hello all,
i have a homework lab/assignment due by 12 tonight. It needs to print out a drawing panel and request 2 names from the user. It should then have a way to take the 2 names entered and create 2 new names in the drawing panel: e.i. "John" would be "Jo" and "hn" and "Mary" which would be "Ma" and "ry" creating "Jory" and "Mahn". Doesnt matter if the names make sense, it just needs to combine the 2. I need a total of 6 old names inputted by the user, and 6 new names that it should output in the drawing panel. Hope that makes sense but i cant figure how to get the names to split and combine to make the new names...help please...heres what i have so far but it has errors in it.

import java.awt.*;
import java.util.*;

public class Names {
  public static void main(String[] args){
    firstName();
    secondName();
    
    Scanner console = new Scanner(text);
    
    DrawingPanel panel = new DrawingPanel (300, 300);
    Graphics g = panel.getGraphics();
    g.setColor(Color.WHITE);
    drawString(OLD NAMES, 0, 0);
  }   
    public static void firstName(char name1) {
      System.out.println("Enter the first name: ");
      name1 = console.nextChar();
    }
    
    public static void secondName(char name2) {
      System.out.println("Enter the second name: ");
      name2 = console.nextChar();
    }
}

Thanks

update,

import java.awt.*;
import java.util.*;

public class Names {
  public static void main(String[] args){
    Scanner console = new Scanner(System.in);
    System.out.println("Enter the first name: ");
    String firstName = console.next();
    System.out.println("Enter the second name: ");
    String secondName = console.next();
        
    DrawingPanel panel = new DrawingPanel (300, 300);
    Graphics g = panel.getGraphics();
    g.drawString("Old Names", 20, 20);
    g.drawString("New Names", 200, 20);
    g.drawString(firstName, 20, 40);
    g.drawString(secondName, 20, 60);
  }   
}

I really need to know how to use a substring to create 2 new names. Please give me an example of how to do that because I think I can get the rest of it from there.

Thanks

This article has been dead for over six months. Start a new discussion instead.