saivinaya Goto Github PK
Name: Vinaya Sai Davuluri
Type: User
Location: Adelaide
Name: Vinaya Sai Davuluri
Type: User
Location: Adelaide
Build a working Ajax shopping cart using the code from the article. So that the TA's have an easy time grading the assignments, Netbeans and Glassfish will be used as demonstrated in class. Name your project ACoolAJAXShoppingCart.
Improve the application by adding a button to each item displayed so that the user may delete items from the shopping cart. Your delete button will behave like the add button, but will count down rather than up. If an item is not currently in the cart then a delete request will be ignored. If a delete request causes a quantity to go to zero then the deleted item will be removed from the cart and no longer displayed. Finally, add a new item to the shopping card catalog. This item will be of your own choosing.
Modify your solution to part 2 so that it uses JSON rather than XML. Note that your servlet will generate a content type of application/json and your XMLHttpRequest object will return JSON via the responseText property rather than the responseXML property. This part requires that you design a JSON string that corresponds to the XML shopping cart. Note that there is a bug in this web application. Enter a few items into the shopping cart and then refresh the page. Only after an additional item is selected will the contents of the cart reappear. Make a simple modification to the index.jsp page to repair this bug.
The Adelaide Hills farm supplies boxes of fresh fruit and vegetable trays to customers. For this Programming Project, define the class FreshBox that contains exactly 4 trays of fruits or vegetables and recipe brochures. Fruits and vegetables have names and any other attributes that you think may be appropriate. Add appropriate constructor, set, and get methods. Also write a method called toString()that returns as a String the complete contents of a FreshBox. Next, write a main method that creates a FreshBox with four trays of fruits or vegetables randomly selected from this list: • Banana • Apple • Cauliflower • Potato • Capsicum For now, you can assume that the list contains exactly five types of fruits or vegetables. Next, the main method should display the contents of the box and allow the user to substitute any one of the five possible fruits or vegetables for any of the fruits or vegetables selected for the box. Since recipe brochures are in short supply the farm only supplies brochures if the FreshBox contains duplicate items. For example, if the box contains 2 trays of potato then the farm adds a “how to make mashed potato” recipe to the FreshBox. After the user is done with substitutions, output the final contents of the box to be delivered.
Once upon a time in the land of Asgard there lived 3 wizards Gandalf, Merlin and Dumbledore. These 3 wizards often had an argument over which one of them was the greatest software developer of all time. To end the argument once and for all, they agreed on a fight to the death. Gandalf was a poor shooter and only hit his target with a probability of 1/3. Merlin was a bit better and hit his target with a probability of 1/2. Dumbledore was an expert marksman and never missed. A hit means a kill and the person hit drops out of the duel. To compensate for the inequities in their marksmanship skills, the three decided that they would fire in turns, starting with Gandalf, followed by Merlin, and then by Dumbledore. The cycle would repeat until there was one man or creature standing, and that man or creature would be the greatest software developer of All Time. An obvious and reasonable strategy is for each wizard to shoot at the most accurate shooter still alive, on the grounds that this shooter is the deadliest and has the best chance of hitting back. Write a program to simulate the duel using this strategy. Your program should use random numbers and the probabilities given in the problem to determine whether a shooter hits the target. Create a class named Fighter that contains the wizard’s name and shooting accuracy, a Boolean indicating whether the fighter is still alive, and a method shootAtTarget(Fighter target) that sets the target to dead if the fighter hits his target (using a random number and the shooting accuracy) and does nothing otherwise. Once you can simulate a single fight, add a loop to your program that simulates 10,000 fights. Count the number of times that each contestant wins and print the probability of winning for each contestant in a tabular format. For example: LEADERBOARD – AFTER 10000 DUELS Contestant Gandalf Merlin Dumbledore Number of Wins 3595 1355 5050 Winning Percentag 35.95% 13.55 50.50% An alternate strategy is for Gandalf to intentionally miss on his first shot. Modify the program to accommodate this new strategy and output the probability of winning for each contestant after 10000 fights. 2|Page What strategy is better for Gandalf, to intentionally miss on the first shot or to try and hit the best shooter? Who has the best chance of winning, the best shooter or the worst shooter?
Write a program that meets the following requirements: • Define a class named Point with two data fields x and y to represent a point’s x and y coordinates. Implement the Comparable interface for comparing the points on x-coordinates and on y-coordinates if x-coordinates are identical. • Define a class named CompareY that implements Comparator<Point>. • Implement the compare method to compare two points on their y-coordinates and on their x-coordinates (only if y-coordinates are identical.) • Randomly create 100 points, add them to an appropriate collections data structure and use an appropriate collections algorithm to display the points in increasing order of their x-coordinates and in increasing order of their y-coordinates, respectively.
Build a shopping cart that allows two or more users to shop together - seeing the same cart from separate machines. Modify the code from the IBM article by McCarthy. When an item is added or deleted, everyone should be notified without polling the server.
In "The Adventure of the Dancing Men," Mr. Sherlock Holmes was asked by a Mr. Hilton Cubitt of Riding Thorpe Manor, Norfolk, to deduce the meaning of his wife's strange behavior, which seemed to stem from several notes left on the sundial in their garden. The notes contained drawings of stick figures, little dancing men in a variety of positions. After accumulating a number of these notes, Holmes concluded that they were a substitution cipher of some sort. Since Holmes was "fairly familiar with all forms of secret writings, and [was himself] the author of a trifling monograph upon the subject," he had no difficulty in breaking the code. He cracked the code by using frequency analysis. (see http://www.dcode.fr/dancing-men-cipher) Holmes' solution used the frequencies with which the 26 letters of the English alphabet appear in normal prose. Write a Java program which will tally letter frequencies in any plain text file a user wants. Find and use an appropriate Collections data structure to store letters and the number of occurrences. Your program should prompt the user to enter a filename, open the file, scan the text character-by-character, and count the occurrences of each of the 26 letters. You should not distinguish between upper and lower case letters, and punctuation should be ignored. Your program should print out each letter and its relative frequency amongst the letters in the file. That is, if there are 300 letters (excluding puncuation and whitespace) in the file, and 24 of them are the letter “w”, then w’s relative frequency is 0.08. Of course, we will test your program on the original Conan Doyle story!
Narnia Cruise Lines has several ships and a variety of cruise itineraries, each involving several ports-of-call. The company wants to maintain information on the sailors and other people who currently work on each of its ships. It also wants to keep track of both its past and future cruises and of the passengers who sailed on the former and are booked on the latter. Each ship has many sailors on it including a captain, engineers, doctors and cooks. The unique identifier of each ship is its ship number. Other ship attributes include ship name, weight, year built, and passenger capacity. Each sailor has a unique sailor identification number, as well as a name, date-of-birth, salary, and nationality. Some of the sailors are in supervising positions, supervising several other sailors and earn 20% more than sailors. Each sailor reports to just one supervisor. The base salary of sailors is $50,000 and the captain gets $300,000. Engineers and cooks make $80,000. A cruise is identified by a unique cruise serial number. Other cruise descriptors include a sailing date, a return date, and a departure port (which is also the cruise’s ending point.) Clearly, a cruise involves exactly one ship and over time a ship sails on many cruises. Each cruise stops at one or usually several ports-of-call, each of which is normally host to many cruises, over time. In addition, the company wants to maintain information about ports that it has not as yet used in its cruises but may use in the future. A port is identified by its name and the country that it is in. Other information about a port includes its population, whether a passport is required for the passengers to disembark there, and its current docking fee, which is assumed to be $20,000 if the ship’s weight is less than 30000 tons, $50,000 if between 30000-50000 tons and $100,000 if the ship’s weight is over 50000 tons. A cruise typically has many passengers on it and on average a ticket costs $900. Passenger information includes a unique passenger number, name, home address, nationality, date-of- birth, money they paid for joining the cruise and moneySpentOnCruise (calculated by totalling amount of money spent by the passenger on-board cruise). Hoping for return business, the company wants to keep track of passengers that may have sailed on several of its cruises (and/or may be booked for a future cruise.) For a person to be of interest to the company, he or she must have sailed on or be booked on at least one of the company’s cruises. The company wants to keep track of how much money each passenger paid for each of their cruises, as well as their satisfaction rating of the cruise, if it has been completed. 1|Page Tasks Design a complete object-oriented system for cruise management based on the above specification. Your system must in the least provide the following features through a console based menu system: 1. Create a cruise with ship, sailors and ports randomly. 2. Add passengers to a cruise. Both manual and random options must be given. 3. Provide reports on the following areas: a. Revenue generated from the cruise passengers by nationality and age b. Details of all Sailors that worked on a cruise and the total cost of paying their salaries and the total cost of docking at different ports c. List of passengers with their details sorted by moneySpentOnCruise d. Cruise evaluation by passengers (assume each passenger completes a 5 question survey at the end of the cruise and generate/store random responses) e. Did the ship make a profit? Use the expenses and earnings from passengers. 4. Information about the cruise including employees, passengers, ports-of-call, and money spent by employees on the cruise must be stored in text files once the cruise is over. Note that this project is open-ended and therefore you are free to implement any additional functionality that you think is necessary based on your design. Most important requirement is the application of OBJECT-ORIENTED DESIGN principles.
Two six-sided dice are rolled. Their sum lies between 2 and 12. Write a program that asks the user for n (the number of rolls) and then simulates the rolling of the two dice n times. You must simulate the rolling of each die and then add to compute the total. When all the rolling is complete your program will draw a bar chart showing the respective frequency of each total. This is a console based application and needs no graphical user interface. Your program will use "*" characters to represent dice rolls. If the number 2 is rolled half as many times as 9 is rolled then 2 will have half as many stars. The number of stars that you use and the design of the output is up to you but must be well done and clear to the user. I recommend that you generate the same number of stars despite the number of requested rolls. That is, each star should represent a percentage of rolls.
Remember the concentration game that you might have played as a kid with some cards. The idea of the game is to find identical pairs among a shuffled pack of cards laid out. For example, let us assume that you are given 10 cards in the deck, with two Aces, two Queens, two 5’s, two Jacks and two labeled 9. The cards are shuffled and placed face down on the table. A player then selects two cards that are face down, turns them face up, and if the cards match they are left face up. If the two cards do not match they are returned to their original face down position. The game continues until all cards are face up. Write a program that plays this game of concentration. Use 16 cards that are shuffled and laid out in a 4 by 4 square. These cards should be labeled with pairs of card numbers (A, Q, K, J, 2, 5, 6, 9). Your program should allow the player to specify the cards that she would like to select through a coordinate system. For example, in the following layout: 1234 1AS$$ 2$$$$ 3$A$$ 4$$$$ All of the cards are face down indicated by $. The pairs of A which are face up and at coordinates (1,1) and (2,3). To hide the cards that have been temporarily placed face up, output a large number of newlines to force the old board off the screen (or find something better in the JAVA API).
Write a method int thisIsIterative(int n) which is defined as follows (you cannot use recursion): • if n < 0 the method returns -10 • if (n==0) the method returns 2 • if (n==1) the method returns 5 • For other values of n the method returns: o thisIsIterative(n-1) + 3 * thisIsIterative(n-2) + 2 * n;
One common security method requires that the amount on a cheque be written in numbers and spelled out in words as well. Even if someone is able to alter the numerical amount of the check, it is extremely difficult to change the amount in words. Write an application that asks the user to input a numeric check amount and writes the word equivalent of the amount. For example, the amount 112.43 should be written as ONE hundred TWELVE and 43/100. A sample run: Please enter a dollar amount: 19.50 Dollar amount in words: NINETEEN and 50/100
Using an appropriate data structure write a program that makes sure a JAVA program’s grouping symbols match correctly. These are symbols like parentheses ( ), curly braces { }, Angle brackets < >, and Brackets [ ]. For example, your program should print an error message (about an incorrect match) if your java source file contains the following class definition: class Wheel { public void inflate(int psi { System.out.println("Inflating to " + psi + "psi"); } } Use command like arguments to read the JAVA source-code file.
Build a Netbeans project with the code found here: http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onmousemove Note that every time the mouse moves (within the box) an event is generated and the x and y coordinates are displayed. It is required that you add your own detailed comments to this code - explaining clearly how it works. The grader will grade based on the quality of these comments.
Create a table named Quiz within a database called ExamDB. You should use the embedded Java DB mode to implement this database. Data is stored in a text file in the following csv format (questionNumber, description, choice1, choice2, choice3, choice4, Answer). Create your own csv text file containing quiz questions. Read from this file and store the records in the Quiz table within the ExamDB database. Give the user a simple MCQ test from your Quiz table with 3 questions each time (one at a time and different each time), and print how many they got right and wrong.
Create a table called Sailor within a database called EmployeeDB. You should use the network Java DB mode (running on localhost) to implement this database.
Write an application that reads a five-letter word from the user and produces every possible three-letter string that can be derived from the letters of that word. For example, the three-letter words produced from the word “bathe” include “ate,” “bat,” “bet,” “tab,” “hat,” “the” and “tea.”
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.