Code in Java. please post as copyable text code, Not an image.
LinkedIntList Programming: Add a removeOdd() method to the LinkedIntList class. This method should remove the odd indexed nodes in the stored linked list. Add the test method to the existing test program. If you have a LinkedIntList with contents of:
[1,2,3,42,56,78,103]
Calling removeOdd() should leave the LinkedIntList looking
like:
[2,42,78]
You must test for possible error conditions. Turn in just your code for the method and your console output for the test. Provide 3 test cases with one exercising your error test.
import java.io.*;
import java.util.*;
class linkedIntList
{
list head;
static class list // class for linked list.static so can't access from main
{
int data;
list next;
list(int num)
{
data=num;
next=null;
}
}
// insertion in linked list
void insert(int num)
{
list n=new list(num);
if(head==null)
head=n;
else
{
list t=head;
while(t.next!=null)
t=t.next;
t.next=n;
}
}
//print linked list
void printList()
{
list t=head;
System.out.print("Linked List is : ");
if(t==null)
System.out.print("Empty");
while(t!=null)
{
System.out.print(t.data);
if(t.next!=null)
System.out.print("->");
t=t.next;
}
}
//delete node at odd position in linked list
void removeOdd()
{
list t=head;
list prev;
if(t!=null)
{
head=t.next;
t=t.next;
}
prev=head;
if(t!=null)
t=head.next;
while(t!=null)
{
prev.next=t.next;
prev=prev.next;
t=t.next;
if(t!=null)
{
t=t.next;
}
}
}
}
public class linkedList
{
public static void main(String args[])
{
int num;
linkedIntList l=new linkedIntList(); // create a object of to access to linkedIntList class members
System.out.println("\nEnter number to insert in linked list or -1 to exit : ");
Scanner in=new Scanner(System.in);
num=in.nextInt();
while(num!=-1) //insert number in linked list until user enter -1
{
l.insert(num);
num=in.nextInt();
}
l.printList(); //print linked List
l.removeOdd(); // remove odd position Node from linked List
System.out.println("\nAfter delete odd Node ");
l.printList();
}
}
screenshot
Code in Java. please post as copyable text code, Not an image. LinkedIntList Programming: Add a...
Java Programming. Please make sure program compiles, the code is
copyable, and screenshots of the output are provided for 5 stars
:-) Calculation for speed is just supposed to be google
searched
1) 18 points] You've been hired by Pedal Punchers to write a Java console application that estimates bicycle speed in miles per hour. Use a validation loop to prompt for and get from the user the wheel diameter of a bicycle in inches in the range 10-50. Then...
please explain how to code using java
-. Implement the ListNode and LinkedIntList as we did in class (you can add other methods if needed). You can reference the coxle in powerpoint slides of LinkedList and your textbook. 2. Implement a LinkedIntList class with the following public operations. a. add(int value) - Adds the given value to the end of the list b.get(int index) - Retums value in list at given index. C.add( int index, int value) - Inserts the...
In Java You may add any classes or methods to the following as you see fit in order to complete the given tasks. Modify the LinkedList (or DoubleLinkedList) class and add a method append. append should take another LinkedList (DoubleLinkedList) as input and append that list to the end of this list. The append method should work by doing a few "arrow" adjustments on the boxes and it should not loop through the input list to add elements one at...
***Please give the java code for the below and add comments for different areas for a dummy to understand*** This java program will combine the techniques of handling arrays, decision control statements, and loops. Your program should accomplish the following: Build an array that holds characters (size 35) Load the array with random capital letters (use random generator) Your program should present a menu to the user allowing for the following “actions”. To “search” for a target letter of the...
Recursion Exercises These exercises provide practice with recursion in Java. Please add notes if possible. Objectives Module: To write recursive solutions for basic problems that require iteration. To identify and address base cases in a recursive method. Reminders during development Each of your solutions to the problems below should be in their own method. If a method header is provided for a problem, then your solution should have that exact method header. Any changes to the method header will receive...
PLEASE HELP ME WITH
QUESTIONS 2 AND 3 WITH COMPILED SOURCE CODE AND OUTPUT. IN C OR
JAVA. DO NOT GIVE INCORRECT ANSWERS.
2. Using your favorite programming language, implement the BST ADT in a linked structure, along with the following operations: search, insert and remove. 3. Implement the InOrder traversal method discussed in class, which shows the keys of the BST n increasing order.
2. Using your favorite programming language, implement the BST ADT in a linked structure, along...
Java programming The purpose of this problem is to practice using a generic Urn class. NOTE: Refer to the code for the ArrayStack class from Chapter 12. Use that code as a starting point to create the Urn class, modifying it to remove the methods in the ArrayStack class (push, pop, etc) then add the methods described below. Also change the variable names to reflect the new class. For example the array name should NOT be stack, instead it should...
Programming Project #5 – Binary Tree
Exercise 19 on page 637 of the text a through f
Here is the array to build the initial binary tree:
int [] data = { 50, 30, 60, 10, 80, 55, 40 };
BUT, make sure the code works with any binary tree created from
an array named data
In addition to the main .java file, make sure you also
create a Node.java and a Tree.java file that contain the code that
allows...
(Java with Netbeans) Programming. Please show modified
programming code for already given Main class, and programming for
code for the new GameChanger class.
// the code for Main class for step number 6 has already
been given, please show modified progrraming for Main class and
GameCHanger class, thank you.
package .games;
import java.util.Random;
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
System.out.println("Welcome to the Number Guessing Game");
System.out.println();
Scanner sc = new Scanner(System.in);
// Get upper...
Given the Interface Code write a java class that implements this interface and show the working functionality in the main method: public interface CustomList<T> { /** * This method should add a new item into the <code>CustomList</code> and should * return <code>true</code> if it was successfully able to insert an item. * @param item the item to be added to the <code>CustomList</code> * @return <code>true</code> if item was successfully added, <code>false</code> if the item was not successfully added (note: it...