Skip to main content

Posts

Showing posts with the label Java

[SOLVED] Java basic concepts

The Instant Lottery Program requires the generation of Random Numbers. For example: n = (int) (Math.random() * (b –a + 1)) + a; What is the operation performed by (int) called? What are the values for a and b in the lottery problem? Math.random() returns a double number in what range? Declaring and assigning Declare an integer variable named aNumber. Assign it the value 107. Make it a named integer constant. Declare a decimal number of type double. Assign the result of A_NUMBER / 3 in a way that keeps the fractional part. Give an example of a count loop and an event loop that you used in your programming assignments. Which type was used in the Instant Lottery Program? How? Why? Draw the top-down design of the Instant Lottery Program. Remember to show how each method relates to the overall solution. Describe the purpose of a driver and a stub used in testing your top-down design. How does Java handle responding to a button press? What are the basic steps to follow? What is an Event and...

Java Arrays program with full source code | Download Now

Program Description Write a program that reads positive numbers (integers) and stores them into an array. Write a method to prompt for the input values. (sentinel terminated) Write a method to print the array. Write a method that returns the value of the smallest number. Write a method that returns the value of the largest number. Write a method to find the location of a number (array index + 1) Write a method to compute the average of the numbers in the array. Write a method to output the results. The input prompt example: Enter at least 10 unique positive numbers (integers) terminated with a sentinel value (-1) Expected Output Amount of numbers read: 10 Numbers read: 12, 33, 41, 1, 4, 10, 7, 21, 66, 50 Smallest number was 1 in location 4 Largest number was 66 in location 9 Average was 24.5 Output Screenshot Download solution now Buy now CONTACT DETAILS For any other questions or other tasks please feel free to contact me via email: mhassnainjamil@gmail.com via WhatsApp: +92-324-70421...

Java Arrays program with full source code | Download Now

Program Description Write a program that reads positive numbers (integers) and stores them into an array. Write a method to prompt for the input values. (sentinel terminated) Write a method to print the array. Write a method that returns the value of the smallest number. Write a method that returns the value of the largest number. Write a method to find the location of a number (array index + 1) Write a method to compute the average of the numbers in the array. Write a method to output the results. The input prompt example: Enter at least 10 unique positive numbers (integers) terminated with a sentinel value (-1) Expected Output Amount of numbers read: 10 Numbers read: 12, 33, 41, 1, 4, 10, 7, 21, 66, 50 Smallest number was 1 in location 4 Largest number was 66 in location 9 Average was 24.5 Output Screenshot Download solution now Buy now

[SOLVED] Java How To Program | Shopping Cart Application | Chapter #29 Ex #29.4 Solution

Shopping Cart Application: Using the techniques you learned in Section 29.8.2, create a simple shopping cart application. Display a list of books as an h:selectOneRadio element. When the user submits the form, store the user’s selection in a @SessionScoped managed bean. Allow the user to return to the list of books and make additional selections. Provide a link to view the shopping cart. On the shopping cart page, display the list of selections the user made, the price of each book and the total of all books in the cart. Get your solution now Buy now

Java Encode Utility source code with full implementation

Hi, this will cover the implementation of encode utility as per the below requirements NOT the test cases. You can test your test cases using this encode utility and verify your test cases. Concise Specification of the encode Utility NAME: encode - encodes words in a file. SYNOPSIS encode OPT <filename> where OPT can be zero or more of -c <integer> -r -d <characters> COMMAND-LINE ARGUMENTS AND OPTIONS <filename> : the file on which the encode operation has to be performed. -c <integer>: if specified, the utility will apply a caesar cipher to all alphabetic characters (other characters remain unchanged and the original capitalization is preserved), incrementing letters by the integer passed in.  -r: if specified, the utility reverse the order of characters in every word, with a word being any set of non- whitespace characters, including non-alphabetic characters, separated from others by any whitespace character....

[SOLUTION] Java with MySQL Software Design & Development Criminal Database Search Engine

Task 1 – Data Import Import the crimedata.sql file into your mysql server database using the PHPMyAdmin application on the LAMP server. Make sure that the import creates a crimedata table and has the following columns: crime_ID, month, reported_by, falls_within, longitude, atitude, location, LSOA_code, LSOA_name, crime_type. The explanation of each column is provided in the appendix A. If imported correctly, your table will have 66,683 records. Task 2– Unit Testing Write Unit Tests for all your classes and methods you implement in tasks 3,5, and 6. Task3 – Database Handling Create a class called DatabaseHandler. This class will have a method called handleDbConnection. It has no input parameters and returns a java.sql.Connection object. You should use your mysql credentials here to make a connection to the database that contains the crimedata table. Other methods and classes implemented as part of tasks below will call the handleDbConnection method to use the connection object a...

Game in Snapshot pattern Java source code download now

Implement In Java the Snapshot pattern depicted In the UML diagram in snapshot.pdf file. Please pay special attention to the access modifiers (+: public, -: private or no sign: package) for each attribute and operation and implement them in Java. The UML diagram follows some of classes defined in the Snapshot pattern in book (page 371) which has more details than in my diagram. Please read the descriptions about them in the book. My MdestonefementolFhas two methods and my private static class Mllestonenemenfo has three attributes. Here are a couple of extra points you need to be aware of: • GameUserInterface class Is the program that user Interacts with. • gets user selected file through JFileChooser  Uses GameSerializer which is the action listener that serializes (saves) GameModel object Into a user-specified file.  Uses GameDeserializer which Is also an action listener that deserializes (read object) from a user specified file.  Gets MilestoneMementoManager fro...

The Race Java Multi-Threading project with complete source code

The Race A number of racers will compete in a race with three obstacles: The Forest, The Mountain and The River. Before the first obstacle and between any two obstacles, the racers will stop for rest and food (by sleeping for a random time). The sequence of events will be something similar to: Rest Forest Rest Mountain Rest River Get Home Note: you will need to keep track of the time when a racer started a specific obstacle and when it ended that obstacle, together with the time when the racer started the race until he finished the race. The obstacles are described below: The Forest: You will have to use the setPriority( ), getPriority( ) and yield( ) methods. At the entry to the forest, the racer will try to rush as much as possible (simulated by increasing its current priority by a randomly generated number between 0-4). The racer using a compass will have to find in the forest a map that contains a magic word. The forest will be a file of more than 300 but les...

[Solution] Banking System implementation in Java Download now

Requirements Our Bank Simulator will consist of information about customer Bank Accounts. I have simplified the requirements for this assignment to set boundaries on your time. The Bank Simulator consists of a dynamically allocated array of BankAccounts of two types – either Savings accounts or Chequing accounts. A bank account consists of an account number (between 100 and 999), customer and a double balance. A Savings account has two additional fields - a rate of interest and a minimum balance amount (at the end of the month, the customer is given interest based on their account balance as long as the account balance is more than the minimum balance amount). A Chequing account has one additional field compared to a Bank Account – that is the monthly fee that is deducted. The Simulator will give the user – presumably the user is a bank employee – a menu of choices of actions (ie this is not simulating a customer using a bank machine). These actions will include adding a new Ba...

Programming Tasks in Java

Task A: Use the following program: Program or Class Name: Description of program or class: What does it do? How do you use it? Author: [your name] Date: */ import java.util.Scanner; public class TaskA { public static void main(String[ ] args) { System.out.print("Enter a word: "); // declare Scanner objects that accept standard input // https://docs.oracle.com/javase/8/docs/api/java/util/Scanner.html Scanner so = new Scanner(System.in); String word = so.nextLine(); String[] chars = word.split(""); System.out.println("The word entered is: " + word); } } Edit, compile, and run the program. Then modify the program to print out only the first and last letters of the entered word. Task B: Modify the program in task 1 by adding specialized methods to accomplish each of the following on the word input by the user: 1. Converts each character of the entered word into an array of Unicode decimal numbers (See: http://unicodelookup.com ) ...

MediRAY chain of pharmacies database design & implementation with Queries

MediRAY Chain of Pharmacies The MediRAY chain of pharmacies has decided to develop a database system to store information of their prescriptions, patients, doctors and related details . They have given the development to your company and your manager has handed over the task to you. Below are the requirements Patients and doctors are persons identified by the personal identification number. The person has address, email and phone number. Patients have patient number (the hospital and the patient number used here ), and their names, addresses, and ages must be recorded. Doctors have doctors registration number. For each doctor, the name, specialty, and years of experience must be recorded. Each pharmaceutical company is identified by name, address, email and has a phone number. For each drug, the trade name and formula must be recorded. Each drug is sold by a given pharmaceutical company, and the trade name identifies a drug uniquely from among the products of that company. If...

Binary Search Tree - Playing with text file data

Program Requirements: Read a text file.  Store the words from the text file into a binary search tree.  To make the problem easier, you may assume that each line in the file contains only one word. (See extra credit below.)  Continue prompting the user for names of text files, reading from text files and adding words to the binary search tree until the user exits the program.  When the program closes, the binary search tree is discarded and when the program starts again, the tree starts in an empty state.  Upon request of the user, display the words stored in the binary search tree in alphabetical order along with the number of times each word appeared in the text file.  In addition, display the total number of words in the tree (count includes duplicates) and the total number of unique words in the tree (not including duplicates).  The words should be case insensitive. That is, "Dog" is equivalent to "doG". If both "Dog" and "doG" app...

[SOLVED] Trivia Game using Linked List, Polymorphism and Inheritance in Java

You will need to first create an object class encapsulating a Trivia Game which INHERITS from Game. The game is the parent class with the following attributes: description - which is a string write the constructor, accessor, mutator and toString methods.  Trivia is the subclass of Game with the additional attributes: trivia game id - integer ultimate prize money - double number of questions that must be answered to win-integer. write the accessor, mutator, constructor, and toString methods. Write a client class to test creating Trivia objects. Once you have successfully created Trivia objects, you will continue by creating a linked list of trivia objects. Your linked list code should include the following: a TriviaNode class with the attributes: trivia game - Trivia object next- TriviaNode write the constructor, accessor, mutator and toString methods. A TriviaLinkedList Class which should include the following attributes: head - TriviaNode number of items - integer write the code f...

Trivia Game using Linked List, Polymorphism and Inheritance in Java

You will need to first create an object class encapsulating a Trivia Game which INHERITS from Game. The game is the parent class with the following attributes: description - which is a string write the constructor, accessor, mutator and toString methods.  Trivia is the subclass of Game with the additional attributes: trivia game id - integer ultimate prize money - double number of questions that must be answered to win-integer. write the accessor, mutator, constructor, and toString methods. Write a client class to test creating Trivia objects. Once you have successfully created Trivia objects, you will continue by creating a linked list of trivia objects. Your linked list code should include the following: a TriviaNode class with the attributes: trivia game - Trivia object next- TriviaNode write the constructor, accessor, mutator and toString methods. A TriviaLinkedList Class which should include the following attributes: head - TriviaNode number of items - integer write the code f...

[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."); } Arrays.sort(A); // sort us...

[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 example of ...

[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 now

[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 adjacent...