English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Write a program called emailaddress that read from the standard input, keyboard input, a users first name and last name. The program should then generate an email address based on the following scheme: take the last name and make the first letter capital letter and the rest of the last name all lower case letter. Take this new last name and appended to it the first letter of the first name in lower case letter. Finally append @hotmail.com to the end of the string. Display the newly generated email address. You can assume no blanks in the first or last name.

Sample input:
Please enter first name:
Shereef
Please enter last name
abualmaati

Sample output:
Your user name is: Abualmaatis@hotmail.com

2007-03-17 18:14:47 · 2 answers · asked by LULU 1 in Computers & Internet Programming & Design

2 answers

These are the methods you would use

Output to screen
System.out.println("message");

Input from keyboard
BufferedReader cin = new BufferedReader(new InputStreamReader(System.in));
String line = cin.readLine();

To get the first letter of the name
String lastName = smith
String letter = lastName.substring(0,1);

To change to upper case
String upper = letter.toUpperCase();

To put all the strings together
String email = lastName + "@hotmail.com"

Just combine all these concepts into a working program.

2007-03-17 18:35:19 · answer #1 · answered by rsmith985 3 · 0 0

import java.io.*;
import java.lang.*;

class pointInsertion{
String fname;
String lname;
String gethalf, mailid;
char firstchar1, firstchar2;
String ATTHENET = "@hotmail.com";
public void point(){
DataInputStream max = new DataInputStream(System.in);
try{
System.out.print("Enter ur First name>> ");
fname = max.readLine(); //getting input
fname = fname.toLowerCase(); //coverting whole string to lowercase
firstchar2 = fname.charAt(0); //getting first letter of firstname

System.out.print("Now enter last name>> ");
lname = max.readLine();
lname = lname.toUpperCase(); //coverting whole string to uppercase
firstchar1 = lname.charAt(0); //getting first char of lastname
gethalf = lname.substring(1); //getting whole string except first letter because we are going to letter half to lowercase, after that we will get first letter as uppercase
gethalf = gethalf.toLowerCase(); //converting letter half string to lowercase
lname = (firstchar1+"").concat(gethalf);
mailid = ((lname).concat(firstchar2+ "").concat(ATTHENET)); //concatinating whole

System.out.println("Generating ur mail id");
System.out.println("Your Mail id is:>> "+mailid);
}
catch(Exception ex){
System.out.println(ex.toString());
}
}
}

class genMail{
public static void main(String[] args){
pointInsertion pI = new pointInsertion();
pI.point();
}
}

2007-03-17 19:30:53 · answer #2 · answered by iMaXX 4 · 0 0

fedest.com, questions and answers