I wrote a code for a "skydiving" program that randomly selects the "maneuvers" to be performed by the skydiver during his skydive. I am almost done with the program. I just need to figure out how to print non repeated maneuvers for each round. Each round may not consist of two of the same maneuvers. The program that I wrote randomly picks the maneuvers but sometimes it still prints out two of the same maneuvers for each round.The following is my code.
import java.util.Scanner;
import java.util.Random;
///v.0
public class Testpart2 {
I wrote a code for a "skydiving" program that randomly selects the "maneuvers" to be performed by the skydiver during his skydive. I am almost done with the program. I just need to figure out how to print non repeated maneuvers for each round. Each round may not consist of two of the same maneuvers. The program that I wrote randomly picks the maneuvers but sometimes it still prints out two of the same maneuvers for each round.
The following is my code
import java.util.Scanner; import java.util.Random; ///v.0 public class Testpart2 { public static void main(String[] args) { Random randomNumbers=new Random();
I have made a program which finds the number of occurrence of the words. It is as follows :
public class B { public static void main(String[] args) { Map<String, Integer> mp = new LinkedHashMap<String, Integer>(); String s = "This is me tarun ohri This"; Scanner p = new Scanner(s); int i = 0;
[Code] .....
Output is coming {This=0, is=1, me=1, tarun=1, ohri=1}
Write a menu driven program that either accepts words and their meanings, or displays the list of words in lexicographical order (i.e. as in a dictionary). When an entry is to be added to the dictionary you must first enter the word as one string, and then enter the meaning as separate string. Another requirement - from time to time words become obsolete. When this happens, such word must be removed from the dictionary.
Use the JOptionPane class to enter the information.
Use the concept of linked list to carryout this exercise. You will need at minimum the following classes:
- A WordMeaning class that hold the name of a word and its meaning. - A WordMeaningNode class that creates the node of information and its link field. - A WordList class that creates and maintain a linked list of words and their meanings. - A Dictionary class that test your classes.
For the output, the program should produce two scrollable lists:
- The current list of words and their meanings. - The list of the deleted words. You need not list the meanings, just the words.
So far, I have everything coded except for the remove method, and I am not sure how to code that. I coded the add method already, but now I don't know where to begin with the remove method in my WordList class. My classes are below.
WordMeaning Class:
public class WordMeaning { String name; String definition; WordMeaning(String t, String d) { name = t; definition = d;
Well my code is supposed to ask for an input file and then (ex: input.txt), read the input file and create an output.txt file with the anagram for the words in the file. Also it should be displayed on the screen. However my code doesn't display the anagram on screen or the output file!
/* This program will read a file given by the user, read the words within the file and determine anagrams of the given words. If the file that the user inputs is empty, then the program will output "The input file is empty." * The program will read the file line by line, counting the total number of words read. If there are more than 50 words, "There are more than 50 words." * will be printed, and the program will terminate. After each line is read, the words in the line will be separated,punctuation characters will be removed, and upper case characters will be switched to lower case. * If any word is larger than 12 characters, that word will not be considered in the total amount of words in the file and it will not be sorted. * After each word is read, the letters will be sorted and stored into an array containing each * word's 'signature'. After all the words have been read, words will be printed to the output file on the same line based upon their signature. */
public class Anagram { //Creating constants for maximum words in file and maximum chars in word public static final int MAX_CHARS = 12; public static final int MAX_WORDS = 50;
So i created a method that basically similar to Math.pow, but using recursion.However, it works fine except it prints the final result twice, how do i get rid of the last repeated number ? here is my method :-
public static int recursion(int base, int degree) { if (degree > 0) { base = base * recursion(base, degree - 1); System.out.println(base);
So I'm trying to write a program that prints out the "most-repeated integer" in an Array.
For example: if an array contains {1,2,2,3} It would print out 2 as the result.This is what I got so far and according to my knowledge I think I'm correct but for some reason it doesn't work.. Please give me some inputs.
public class MostInt{ public MostInt (){ int[] array = {0}; for(int i = 0;i>array.length;i++){ if(i==i++){ System.out.println(i);
public class ProcessMarks { private static final int NMARKS = 125;
[Code] ...
Result (it's repeat number): *Mode is = 53 *Mode is = 53 *Mode is = 53 *Mode is = 53 *Mode is = 53 *Mode is = 62 *Mode is = 62 *Mode is = 62 *Mode is = 62 *Mode is = 62 *Mode is = 67 *Mode is = 67 *Mode is = 67 *Mode is = 67 *Mode is = 67 *Mode is = 77 *Mode is = 77 *Mode is = 77 *Mode is = 77 *Mode is = 77 *Mode is = 78 *Mode is = 78 *Mode is = 78 *Mode is = 78 *Mode is = 78 *Mode is = 85 *Mode is = 85 *Mode is = 85 *Mode is = 85 *Mode is = 85
Result that i want it to be (number appear only once):
*Mode = 53, 62, 67, 77, 78, 85
or
*Mode is = 53 *Mode is = 62 *Mode is = 67 *Mode is = 77 *Mode is = 78 *Mode is = 85
I was trying to create a java program which can remove the repeated characters in a String. For ex-
Input: kamehamehaaa Output: kameh
Here is my code:-
import java.util.Scanner; class replace { public static void main (String args[]) { Scanner br = new Scanner(System.in); System.out.println("Enter a word");
[Code] ....
On executing the program, StringOutOfBoundsIndex error occurs.
So in my parallel array i read from a textfile of strings and if i enter the string into the string array and if strings are repeated i store it in a parallel array that counts repeated instances. I'm supposed to get 27 15 21 23 20 but instead i get 106 0 0 0 0....
Operating System = Windows 7 version 6.1 running on amd64 Java; VM; Vendor = 1.8.0 Runtime = Java HotSpot(TM) 64-Bit Server VM 25.0-b70
Detect a bug in Java, specifically in the Calendar class will getDisplayName method. I put in the message code showing the error. If the code is executed you can see that the month March be repeated 2 times jumping the month of February.
Code Example:
import java.util.Calendar; import java.util.Locale; public class BugInCalendarDisplayName { public static void main(String[] args) { Calendar aMonth = Calendar.getInstance(); aMonth.set(Calendar.MONTH, 0);
[Code] ....
Obtained results of the code execution:
ENERO MARZO MARZO ABRIL MAYO JUNIO JULIO AGOSTO SEPTIEMBRE OCTUBRE NOVIEMBRE DICIEMBRE
I have to make a program that prompts the user to enter 10 numbers and at the end it prints out the distinct numbers and then the other numbers that weren't repeated...
I have the part where it prints out the distinct numbers but I stuck on how to make it print out the other numbers that didn't repeat...
import javax.swing.JOptionPane; public class DistinctNumbers { public static void main(String[] args) { String getInput; int input; int[] numbers = new int[10];
I'm very new to Java and need to write a program where the user inputs any number from -999 to 999 and it inputs it in words. For ex -24 entered would print negative twenty four or 800 entered would be eight hundred. I need to have at least 2 methods that need to be returned to the main method. When i compile, it says that cannot convert from void to java.lang.string for all the word = ... in my case statements.
import java.util.Scanner; public class NumToText { public static void main (String args[]){ Scanner input = new Scanner (System.in) ; System.out.println ("Enter number."); int number = input.nextInt ();
So my goal is to build a word search here. The road block I have run into is how to save words, input from user, into an array. Then once I figure that out I need to try and arrange them in such a way so that they will fit into my array without screwing with one another. It does not have to be working exceedingly well I mean really it can be assumed that the users will not try to screw the program up. Ie one or two words and a fairly large table will be all the input. Here is the program as of now:
import java.util.Random; import java.util.Scanner; public class BuildWS { int r; int c; char[][] array; String query = " ";
I was browsing around and I found a question asking to find how many times a word occurred in a sentence. I am using a hashtable, over kill yes but I need to use them more. However my counter is not working, not really sure why.You can see in the main method I have two repeating names but it returns 0.
package frequency; import java.util.Hashtable; public class CheckFrequency { hashtable<String, Word> words = new Hashtable<String, Word>();
I am learning to use heaps and as an exercise I am trying to write a program using a heap class I have created to sort words. I have read in words from a file and added them to the heap successfully. I am having some trouble figuring out how I can print out a sorted list of the words. From my understanding of how a min-heap works, if I remove from the min/root node they will always be removed in sorted order. So far I have tried out to do a simple for loop but, only half of the heap is being removed. Not sure if my logic is incorrect of there is an error somewhere in my removeMin() function specifically in the while loop.
public static void main(String[] args) { Heap heap = new Heap(); heap = read( heap ); for( int i = 0; i < heap.getSize(); i++){ heap.removeMin();
I want to write an application that inputs a sentence, tokenizes the words with method split and reverse the words (not the letters)...I am stuck at the last part: how to reverse them...should I use the method reverse(); ?
Here is my code..
import java.util.Scanner; import java.util.StringTokenizer; public class ReversedWords { //execute application public static void main( String [] args) { //get sentence
I have these sample strings in a text file : goldfish, fish, dish, filter and i need to extract them out with letters : "is" and need to print them out in another text file. Currently I am able to read the contents of the file but I am not able to print the same it in the new file.
public class Demo { public static void main(String[] args) { String filename = "a.txt"; try {
Aeparated by blanks in a string. For simplicity, use strings without punctuation or other white space characters(tabs, newlines etc). Use a JTextArea to allow the user to enter the text and allow the text area to scroll if necessary. when the user clicks a button to count the words , the total number of words counted is displayed in a textbox that cannot be modified by the user.
now my problem is that i am not getting the counted number to display in the un-editable textbox. i also have the problem where the cusrsor is showing in the middle of the input screen instead of at the top.
import java.io.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.text.*; import java.util.*; public class WordCounter extends JFrame implements ActionListener
What I am trying to do is extract the digits from between the words 'deal' and 'of'. I was wondering if this was possible to do with a regular expression or if I should just use a scanner.
UNIQUE Passive - Cleave: Basic attacks deal 20% to 60% of total Attack Damage as bonus physical damage to enemies near the target on hit (enemies closest to the target take the most damage).
Is there a regular expression that I could use in order to extract the '20' and the '60' from the above text. Below is what I have tried, but does not work.
(?<=deals)(d+(?=%))(?=of)
just to make a clarification, these numbers will not be the only numbers and the strings themselves will change. Everything can be considered a variable. The only constants between each string would be the words 'deal' and 'of'. The regex pattern "d+" is not a viable expression for my case