Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

What is the code of this Java program? Please help Write a program which prompts

ID: 668913 • Letter: W

Question

What is the code of this Java program?

Please help

Write a program which prompts the user for input using the JOptionPane class. The dialog window prompts the user for their ID. A valid user ID must be at least 6 characters in length and no longer than 10 characters. If a valid user ID is entered display, "Welcome, (input) My name is Hal When the user name's length is outside this range display, "Sorry, user ID invalid". Use an efficient selection control structure. Shown below is an example of the program executing. Input Message ? Please enter your wser in Sorry, user Ds invalid Input 3 Message Pleese ester your user ID Welcome, dsmithg ty name is Ha

Explanation / Answer

import javax.swing.*; import java.util.*; import java.awt.*; import java.awt.event.*; public class HolidayRequest //extends JFrame implements ActionListener { public static void main(String[] args) { String[] colours = {"b","g","y"}; JComboBox box = new JComboBox(colours); int result; do { String[] choice = {"Enter Your UserName", "Holidays Avaliblity", "Quit"}; result = JOptionPane.showOptionDialog (null,"Choose an option", "Holiday Request", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, choice, "Enter a word"); switch(result) { case 0: enterUserName(); break; case 1: HolidaysAvaliblity(); break; } } while(result != 2); System.exit(0); } /*String[] colours = {"b","g","y"}; JComboBox box = new JComboBox(colours); public HolidayRequest() { setTitle("Combom Box"); setLayout(new FlowLayout()); add(box); box.addActionListener(this); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(250, 250); setVisible(true); } public void actionPerformed(ActionEvent e) { String item = (String) box.getSelectedItem(); if(item.equals("b")) { getContentPane().setBackground(Color.red); } box.setSelectedIndex(0); }*/ private static void enterUserName() { char first, last; String word, message; word = JOptionPane.showInputDialog(null, "EnterUserID",null, JOptionPane.PLAIN_MESSAGE); if(word != null) { if(word.length() != 0) { word = word.toUpperCase(); first = word.charAt(0); last = word.charAt(word.length() -1); if(first == last) { message = "You entered the Correct ID StartDate Request EndDate"; } else { message = "you did not enter the Correct ID"; } JOptionPane.showMessageDialog(null, message, null, JOptionPane.INFORMATION_MESSAGE); } else { message = "you did not enter the Correct ID!"; JOptionPane.showMessageDialog(null, message, null, JOptionPane.ERROR_MESSAGE); } } } private static void HolidaysAvaliblity() { int answer; answer = JOptionPane.showConfirmDialog(null, "are you sure you want to know the avaliblities?", null, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if(answer == JOptionPane.YES_OPTION) { JOptionPane.showMessageDialog(null, "The Avaliblity Table is listed below"); } } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote