Posts

[SOLVED] Buggy Search And Sort Buy Reporting with Java source code

Report The Bug From The Following Source Code: import java.util.Arrays; /** * This class looks like it's meant to provide a few public static methods for * searching and sorting arrays. It also has a main method that tests the * searching and sorting methods. *  * TODO: The search and sort methods in this class contain bugs that can cause * incorrect output or infinite loops. Use the Eclipse debugger to find the bugs * and fix them */ public class BuggySearchAndSort { public static void main(String[] args) { int[] A = new int[10]; // Create an array and fill it with random ints. for (int i = 0; i < 10; i++) { A[i] = 1 + (int) (10 * Math.random()); } int[] B = A.clone(); // Make copies of the array. int[] C = A.clone(); int[] D = A.clone(); System.out.print("The array is:"); printArray(A); if (contains(A, 5)) { System.out.println("This array DOES contain 5."); } else { System.out.println("This array DOES NOT contain 5....

[SOLVED] Implementation of hash tables from scratch in Java with full source code

The fact that Java has a HashMap class means that no Java programmer has to write an implementation of hash tables from scratch -- unless, of course, you are a computer science student. For this exercise, you should write a hash table in which both the keys and the values are of type String. (This is not an exercise in generic programming; do not try to write a generic class.) Write an implementation of hash tables from scratch. Define the following methods: get(key), put(key,value), remove(key), containsKey(key), and size(). Remember that every object, obj, has a method obj.hashCode() that can be used for computing a hash code for the object, so at least you don't have to define your own hash function. Do not use any of Java's built-in generic types; create your own linked lists using nodes as covered in section 9.2.2 of the textbook. However, you do not have to worry about increasing the size of the table when it becomes too full. Get your project now  Buy now

[SOLVED] Coke Machine Project in java with full source code

Purposes of this project: get you started using basic Java constructs, including: The use of Scanner to get user input Declarations, assignment statements, if and while statements. System.out.print and println methods. General idea: Simulate the operation of a Coke machine. This machine offers Coke, Coke Zero, and Caffeine-free Diet Coke. All drinks cost $1 (100 cents). The machine does not take dollar bills or pennies, but it does take nickels, dimes, and quarters. When enough money has been entered, a drink may be selected, and any change is returned (the specific coins are listed).Only coins in denominations of 5, 10, and 25 cents are accepted. Any other denomination (33 cents, 50 cents, etc.) is rejected and returned. More than one drink may be purchased (that is, the program doesn't quit after selling one drink).There is no way to turn off the coke machine. When you run the program from within Eclipse, you can stop it by pressing the red square. Example: Here is an ex...

[SOLVED] Product listing and sorting program in Java with full source code

(Manipulating a Stream<Invoice ) Use the class Invoice to create a List of Invoice objects. Use the sample data shown in the Fig. Class Invoice includes four properties PartNumber (type int ), PartDescription (type String ), Quantity of the item being purchased (type int ) and Price (type double ). Perform the following queries on the List of Invoice objects and display the results: Use lambdas and streams to sort the Invoice objects by PartDescription , then display the results. Use lambdas and streams to sort the Invoice objects by Price , then display the results. Use lambdas and streams to map each Invoice to its PartDescription and Quantity , sort the results by Quantity , then display the results. Use lambdas and streams to map each Invoice to its PartDescription and the value of the Invoice (i.e., Quantity * Price ). Order the results by Invoice value. Modify Part (d) to select the Invoice values in the range $200 to $500. Get your solution now  Buy no...

[SOLVED] Airplane seat reservation system in java with full source code

In this project, you will implement an airplane seat reservation system. An airplane has two classes of service (first and economy). Each class has a sequence of seat rows. The following figure shows the seat chart of the airplane. A reservation request has one of two forms. One form is that an individual passenger request consists of the passenger name, a class of service, and a seat preference such as W(indow), C(enter), or A(aisle) seats. The reservation program either finds a matching seat (the search may start from the first row of the class.) and reserves it for the passenger, or it fails if no matching seat is available. (For example, if the user's preference is a W(indow) seat and none is available, tell the user no Window seat is available and ask for another seat preference.) The other form is that a group request consists of a list of passenger names and a class of service. (Groups cannot specify a seat preference). The reservation program finds the first row of adjace...

[SOLVED] Java Programming Questions with full source code

Question 1 Write a Java program to compose a random sequence of 10 case-sensitive letters. Allowable letters are: C,D,E,F,G,A,B,c,d,e,f,g,a,b. Assign random values to each letter. Allowable values are 4,3.5,3,2.5,2,1.5,1,0.5. Display a comma separated list of each generated letter followed by its assigned value. Do not include a space between the letter and its assigned value. Use an array as part of the solution to this question. Question 2 Write a program that prompts the user for a character in the range of a-z (inclusive) and 3 integers in the range of 1-9 (inclusive). The program should convert the character into lowercase and get its numeric equivalent (where a is 1, b is 2 … z is 26) and multiply the numeric equivalent by the sum of the integer inputs. The program should print the inputs and the total in CSV format to a file. The first line in the file should contain headings. The second line should contain the values. Each output should be separated by the | symbol. The ...

[SOLVED] Solver for Sudoku puzzles in Java with full source code

Introduction The purpose of the project is to try in practice the use of recursion and object-oriented program design. Please make sure to read this entire note before starting your work. Pay close attention to the sections on deadlines, deliverables, and exam rules. The problem Your task in this part of the project is to write a solver for Sudoku puzzles. Sudoku puzzles are a kind of crossword puzzles with numbers where the following two conditions have to be met: In each row or column, the nine numbers have to be from the set [1,2,3,4,5,6,7,8,9] and they must all be different. For each of the nine non-overlapping 3x3 blocks, the nine numbers have to be from the set [1,2,3,4,5,6,7,8,9] and they must all be different. The following two figures show a Sudoku puzzle and its solution. The input The input of your program, the Sudoku puzzles, is given in text files. More specifically, they are represented as nine lines of nine characters separated by spaces. The characters can b...