- #1
clook
- 35
- 0
So I have to create a UML diagram for my program:
My professor wants me to do it like so:
Class
Variables
Objects
Methods.
I came up with this but I'm not exactly sure I did it right.
NameDate
Variables
firstNameString
middleNameString
lastNameString
Objects
todayDate
formattingSimpleDateFormat
Methods
System.out.print
System.out.println
inputScanner
Code:
import java.util.*;
import java.text.*;
public class NameDate {
public static void main(String[] args) {
// Input the first, middle, and last name
// Display the name and the date.
String firstNameString, middleNameString, lastNameString;
//Create a Scanner object
Scanner inputScanner = new Scanner(System.in);
//Objects needed for date.
Date todayDate = new Date();
SimpleDateFormat formattingSimpleDateFormat=
new SimpleDateFormat("MMMM dd yyyy");
//Input the data
System.out.print("Enter your first name ");
firstNameString = inputScanner.next();
//middleNameString enter middle name.
System.out.print("Enter your middle name ");
middleNameString = inputScanner.next();
System.out.print("Enter your last name ");
lastNameString = inputScanner.next();
//Print out first, middle, and last name with date.
System.out.println("Hello" + " " + lastNameString + "," + " " + firstNameString + " " + middleNameString.substring(0,1) + "." + " " + "Today is" + " "
+ formattingSimpleDateFormat.format(todayDate));
}
}
My professor wants me to do it like so:
Class
Variables
Objects
Methods.
I came up with this but I'm not exactly sure I did it right.
NameDate
Variables
firstNameString
middleNameString
lastNameString
Objects
todayDate
formattingSimpleDateFormat
Methods
System.out.print
System.out.println
inputScanner