-
Notifications
You must be signed in to change notification settings - Fork 0
/
BusinessLetter.java
35 lines (33 loc) · 922 Bytes
/
BusinessLetter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import javax.swing.*;
public class BusinessLetter
{
public static void main(String[] args)
{
String name;
String firstName = "";
String familyName = "";
int x;
char c;
name = JOptionPane.showInputDialog(null,
"Please Enter Customer's First and Last Name");
x = 0;
while(x < name.length())
{
if(name.charAt(x) == ' ')
{
firstName = name.substring(0, x);
familyName = name.substring(x + 1, name.length());
x = name.length();
}
++x;
}
JOptionPane.showMessageDialog(null,
"Dear " + firstName +
",\nI am so glad we are on a first name basis" +
"\nbecause I would like the opportunity to" +
"\ntalk to you about an affordable insurance" +
"\nprotection plan for the entire " + familyName +
"\nfamily. Call A-One Family Insurance today" +
"\nat 1-800-555-9287.");
}
}