Answered step by step
Verified Expert Solution
Question
1 Approved Answer
this assignment has two parts (JAVA PLEASE) part two: Write a program that creates a linked list of integers, assigns integers to the linked list,
this assignment has two parts (JAVA PLEASE)
Write a program that creates a linked list of integers, assigns integers to the linked list, prints a range of values in the list and eliminates duplicate numbers in the list. Your program must have two methods: First method is called printRange which has two parameters, and y. printRange should write out all integers in the list that are between the first occurrence of X (inclusive) and the first occurrence of y (but not including y). You may assume integers can be compared for equality using == Use the following header for the method: void printRange (int x, int y); Use the following logic to develop printRange This makes the implementation easier. . Print integers from x to y including but not including y If there isn't an entry with a value equal to x, then print nothing If there isn't an entry after x, that has a value equal to y, then print the integers from x (inclusive) to the end of the list Print the values on one line separated by space. . Put an end of line after the values are ALL printed. Hint, your program will need to make multiple calls to printRange For this program, you are (hard coding creating your data in the program, and not entering it from the console. In your program create a linked list with the following members: (1, 1, 2, 3, 3, 75, 4, 4, 8, 9). Review the sample output below. You MUST USE the values for x and y, shown (shown in bold) as parameters in multiple calls to printRange to test the logic of your program Below is a sample output.. // Comments List [1,2,3,4,5,6,7) Il x = 2 y = 5 prints 2 3 4 // prints list including x but not y List [1,2,3,4,5,6,7) Il x = 2 y = 78 prints 2 3 4 5 6 7 List [1,2,3,4,5,6,7) prints 2 3 4 5 6 7 List (1,2,3,4,5,6,7) // prints list including x, no value -y so print to end // x = 2 y = 1 Il prints list including x, no value=y so print to end Il x = 8 y = 5 Il prints nothing The second method is called removeRepetitions. removeRepetitions steps through the linked list comparing numbers and when duplicate numbers are found, removes one of the duplicate numbers. Again, you may assume integers can be compared for equality using == Use the following header for the method removeRepetitions: void remove_repetitions() Here is a brief outline of an algorithm for removeRepetitions: variable p steps through the list for each number in the list, define a new variable q equal top While q is not the last number in the list If the next number has data equal to the data in p. remove the next number Otherwise move to the next number Write a program that repeatedly prompts the user to guess the capital of a randomly displayed state. Upon receiving the user input, the program reports whether the answer is correct. Your program must run a minimum of 5 times and display the total number of correct answers. The user's answer is not case-sensitive. I have provided the list of states and capitals for you "Alabama", "Montgomery"}, 1 "Alaska", "Juneau"). "Arizona", "Phoenix"), {"Arkansas", "Little Rock"}, {"California", "Sacramento"}, {"Colorado", "Denver"), {"Connecticut", "Hartford"), ("Delaware", "Dover"}, {"Florida", "allahassee"), "Georgia", "Atlanta"), "Hawaii", "Honolulu"). {"Idaho", "Boise"), {"Illinois "Springfield"), ("Maryland", "Annapolis"), 1 "Minnesota", "Saint Paul"}, "Towa", "Des Moines"), "Maine", "Augusta"), {"Kentucky", "Frankfort"), {"Indiana", "Indianapolis"}, {"Kansas", "Topeka"), {"Louisiana", "Baton Rouge"}, "Oregon", "Salem"), "Oklahoma", "Oklahoma City"), { "Ohio", "Columbus"}, "North Dakota", "Bismark"), New York", "Albany"), 1 "New Mexico", "Santa Fe), { "New Jersey", "Trenton"}, {"New Hampshire", "Concord"). "Nevada", "Carson City"}, 4 "Nebraska", "Lincoln"), ("Montana", "Helena"), ("Missouri", "Jefferson City"}, {"Mississippi", "Jackson"), { "Massachusettes", "Boston" }, "Michigan", "Lansing"). {"Pennslyvania", "Harrisburg" }, { "Rhode Island", Providence"). "South Carolina", "Columbia"), {"South Dakota", "Pierre"), { "Tennessee", "Nashville"), "Texas", "Austin"), { "Utah", "Salt Lake City"), {"Vermont", "Montpelier"}, {"Virginia", "Richmond"}, ("Washington", "Olympia"), ("West Virginia", "Charleston"), ("Wisconsin", "Madison"), ("Wyoming", "Cheyenne") part two:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started