
ASSIGNMENT
Write a Java program that meets these requirements.
• Create a NetBeans project named LastnameAssign1. Change Lastname to your last name. For example, my project would be named NicholsonAssign1.
• In the Java file, print a welcome message that includes your full name.
• The program should prompt for an XML filename to write to
o The filename entered must end with .xml and have at least one letter before the period. If it does not, print a warning and prompt again. Keep nagging the user until a proper filename is entered.
• Prompt the user for 3 integers.
o The three integers represent red, blue, and green channel values for a color.
o Process the numbers according to the instructions below
o Once you have handled the 3 input values, prompt the user again
o Keep prompting the user for 3 integers until the user enters the single word DONE
o Reading input should not stop for any reason except for when the user enters DONE.
o The user will not mix DONE and the numbers. The user will either enter 3 integers OR the
word DONE
• Once the user is done, open the filename entered in the first step and output the data.
o If no numbers were entered, then do not open the file for writing. Simply print a message
that no data was entered.
o When 1 or more colors are entered, write out the XML data for each color. See below for
the format.
o Sometimes users may enter integer values that are larger than 255 or less than 0. Values
like this will need to be “clipped”, that is, converted to good values. For example, if the user
enters 300 for red, then the actual red channel value will be 255. If the user entered -10 for
the blue channel, then the actual blue channel value will be 0.
You should follow the sample below and your program should exhibit the same behavior.
For full credit, your generated XML files must pass validation with NetBeans Check XML.
XML FORMAT
The very first line of the XML file must look exactly like this:
<?xml version="1.0" encoding="utf-8" ?>
After that line, the root element should be
<quiz>
For every number entered in the program there should be a
<question>
element child of the assignment element. The question element should have an attribute called
num. Its value is a number that should start at 1 for the first question, then 2 for the second question, and
so on. The whole start tag for a question should follow this pattern:
<question num="1">
except the value for the attribute will be different.
There should be a question element for each color (3 integers) the user entered. For example, if the user
entered values for 4 colors during the input, then the XML file will have 4 question elements inside its
assignment element.
Inside each question element, there will be four child elements:
1. <data> - this will contain the values entered by the user. Inside <data>, there will be three
more elements: <red>, <green>, and <blue>. For example, if the user entered 255 for red, 0
for green, and 0 for blue, then this element would be:
<data>
<red>255</red>
<green>0</green>
<blue>0</blue>
</data>
2. < rgb-int> - this will be the rgb version with three integers in the range of 0 - 2255. For
example:
<rgb-int> rgb(255, 0, 0) </rgb-int>
3. < rgb-pct> - this will be the rgb version with three percentages. For example:
<rgb-pct> rgb(100.0%, 0.0%, 0.0%) </rgb-pct>
4. <hex> - this will be the color in hexadecimal format. For example:
<hex> #ff0000 </hex>
For example, suppose the fifth color the user entered the values 102 for red, 51 for green, and 255 for blue,
then entire question element for that number would be:
<question assign-num="5">
<data>
<red>102</red>
<green>51</green>
<blue>255</blue>
</data>
<rgb-int> rgb(102, 51, 255) </rgb-int>
<rgb-pct> rgb(40.0%, 20.0%, 100.0%) </rgb-pct>
<hex> #6633ff </hex>
</question>
As mentioned previously, the user may enter values for the color channels that are greater than 255 or less
than 0. In that case, the values entered by the user should be shown in the <data> element as entered.
The incorrect values should be clipped for the <rgb-int>, <rgb-pct>, and <hex> elements. For
example, for the 6th question, if the user entered the values 300 for the red channel, 153 for the green
channel, and -117 for the blue channel, the question element would be:
<question assign-num="6">
<data>
<red>300</red>
<green>153</green>
<blue>-117</blue>
</data>
<rgb-int> rgb(255, 153, 0) </rgb-int>
<rgb-pct> rgb(100.0%, 60.0%, 0.0%) </rgb-pct>
<hex> #ff9900 </hex>
</question>
A full example is provided in the file sample.xml.
SAMPLE RUN
The following is a sample run. Your program should have similar prompts and work the same. Make sure
the greeting has your name. The blue, bold items are the values entered by the user.
--- Welcome to Harry Potter's Color Quiz Answer Generator ---
Enter the filename the data be saved to
sample.xml
Enter 3 integers, or the word DONE to stop:
255
0
0
Enter 3 integers, or the word DONE to stop:
75
99
42
Enter 3 integers, or the word DONE to stop:
999
-888
51
Enter 3 integers, or the word DONE to stop:
68
255
5
Enter 3 integers, or the word DONE to stop:

Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 1 images

- >> classicVinyls.cpp For the following program, you will use the text file called “vinyls.txt” attached to this assignment. The file stores information about a collection of classic vinyls. The records in the file are like the ones on the following sample: Led_Zeppelin Led_Zeppelin 1969 1000.00 The_Prettiest_Star David_Bowie 1973 2000.00 Speedway Elvis_Presley 1968 5000.00 Spirit_in_the_Night Bruce_Springsteen 1973 5000.00 … Write a declaration for a structure named vinylRec that is to be used to store the records for the classic collection system. The fields in the record should include a title (string), an artist (string), the yearReleased (int), and an estimatedPrice(double). Create the following…arrow_forwardJAVASCRIPT: Part I– For you “Login.html” page, we are going to do some Javascript validating. First validate that the user typed in something in both textboxes. If either textbox is empty, pop-up a message that tells the user that they must enter a Valid Customer ID and Password. Part II– Again for you “Login.html” page, validate that the Customer ID is a Number, not a string. Also all Customer IDs are numbers between 3000 and 3999. All 4 digit numbers. Validate that all Customer IDs are numbers between 3000 and 3999.arrow_forwardThis should be done with Visual Studio C# console app net core Thanks!arrow_forward
- Create a new file cart.html You must get and set the data on the web page by using document.getElementById( ). Each HTML element on the web page already has an id so it is easy. No need for a loop to go through the list of products, there is only 2 products and the info is hard coded on the web page. You must write the code for function cartTotal().arrow_forwardPython Required information id fname lname company address city ST zip 103 Art Venere 8 W Cerritos Ave #54 Bridgeport NJ 8014 104 Lenna Paprocki Feltz Printing 639 Main St Anchorage AK 99501arrow_forwardFocus on string operations and methods You work for a small company that keeps the following information about its clients: • first name • last name • a 5-digit user code assigned by your company. The information is stored in a file clients.txt with the information for each client on one line (last name first), with commas between the parts. For example Jones, Sally,00345 Lin ,Nenya,00548 Fule,A,00000 Smythe , Mary Ann , 00012 Your job is to create a program assign usernames for a login system. First: write a function named get_parts(string) that will that will receive as its arguments a string with the client data for one client, for example “Lin ,Nenya,00548”, and return the separate first name, last name, and client code. You should remove any extra whitespace from the beginning and newlines from the end of the parts. You’ll need to use some of the string methods that we covered in this lesson You can test your function by with a main() that is just the function call with the…arrow_forward
- Could you help me with this one too, please Regex, APIs, BeautifulSoup: python import requests, refrom pprint import pprintfrom bs4 import BeautifulSoup complete the missing bodies of the functions below: def group_chat(text_message, friend):"""Question 2- Your friends are blowing up your group chat. Given a string of text messagesfrom your friends and a specific friend's name, return the first text messagethey sent, excluding their name.- Each text message ends with either a ?, !, or .- Your code must be written in one line. Args:text_message (astr)friend (astr)Returns:str of first match>>> text_message = "Madison: How are you guys going today?" + \"Anna: I'm doing pretty well!" + \"Madison: That's good to hear. How is everyone else?">>> friend = "Madison">>>group_chat(text_message, friend)How are you guys going today?"""pass test code: # text_message = "Madison: How are you guys going today?" + \# "Anna: I'm doing pretty well!" + \#…arrow_forwardThis is for Advanced Java Programming Write a test program that reads words from a text file and displays all non-duplicate words in ascending order and then in descending order. - The file is to be referenced in the program, not needing to be used as a command line reference. - The word file is to be titled collection_of_words.txt and included in your submission. Write test code that ensures the code functions correctly.arrow_forwardA bucket list is a collection of goals, dreams, and aspirations that you would like to accomplish within your lifetime. The purpose of this assignment is to develop a program that allows the user to manage their personal bucket list and save it to an XML file bucketlist.xml. For full credit, run the program and create a file with at least three entry elements. Submit a document containing a copy of the source file, a screenshot of the program in action, and the contents of the XML file. File Structure Below is the basic structure (i.e. schema) for the XML file. You may add additional elements. <bucketList> <entry> <rank></rank> <description></description> <status></status> </entry> </bucketList> Note: Before running the program, manually create an XML input file with at least one entry element that contains values in each child element. GUI Requirements At a minimum, your GUI must meet the below requirements. No minimize…arrow_forward
- JAVA PPROGRAM ASAP Please Modify this program ASAP BECAUSE IT IS HOMEWORK ASSIGNMENT so it passes all the test cases. It does not pass the test cases when I upload it to Hypergrade. Because RIGHT NOW IT PASSES 0 OUT OF 1 TEST CASES. I have provided the failed the test cases and the inputs as a screenshot. The program must pass the test case when uploaded to Hypergrade. import java.io.File;import java.io.FileNotFoundException;import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); String fileName; System.out.println("Please enter the file name or type QUIT to exit:"); fileName = keyboard.nextLine().trim(); while (!fileName.equalsIgnoreCase("QUIT")) { File file = new File(fileName); if (file.exists()) { int wordCount = countWords(file); System.out.println("Total number of words: " + wordCount + "\n);…arrow_forwardLab Tasks – complete these Use the information provided here, in the slideshow and in chapter 12 of our text to do the following exercise. Step 1: On the desktop or wherever you will be saving your java program, use notepador other basic text editor (NOT WORD) to create a .txt file. In this file, type out a list of 10 integers (one on each line or with a space between each). Save. Do this manually. Not with Java. Step 2. Now write a program with the following: 1) In the program creating a File object that connects to the .txt file that you just created. 2) Add code that will check if the file exists and if it doesn’t, it will create it. (Yes, we know it definitely exists but do this part anyway.) 3) Set up a Scanner so that you can read the values from the file and print them to the screen using a loop. You will probably need to use the .hasNext() method. Also, you may want to set up a counter to keep track of how many values there are for future use. (Note that the .length()…arrow_forwardScenario: You have been tasked with building a URL file validator for a web crawler. A web crawler is an application that fetches a web page, extracts the URLs present in that page, and then recursively fetches new pages using the extracted URLs. The end goal of a web crawler is to collect text data, images, or other resources present in order to validate resource URLs or hyperlinks on a page. URL validators can be useful to validate if the extracted URL is a valid resource to fetch. In this scenario, you will build a URL validator that checks for supported protocols and file types.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





