Skip to content

Instantly share code, notes, and snippets.

@Josebuendia
Created November 22, 2019 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Josebuendia/4a0f2cd2852fc29124e7e8c3a5878034 to your computer and use it in GitHub Desktop.
Save Josebuendia/4a0f2cd2852fc29124e7e8c3a5878034 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
/*@ Fintan*/
public class NameApp{
public static void main(String args[]){
//declare variables
String name;
int length;
char firstLetter, lastLetter;
Scanner input;
//declare & create objects
Name myName = new Name();
input = new Scanner (System.in);
//input
//prompt
System.out.println("Please enter your name");
name = input.next();
myName.setName(name);
//process
myName.compute();
//output
length = myName.getLength();
firstLetter = myName.getFirstLetter();
lastLetter = myName.getLastLetter();
System.out.println("Your name has " + length+" letters. The first letter is " +firstLetter+" and the last letter is " + lastLetter);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment