I have to make a program on J2Me which I don't have a clue, the question is :
-------------
"Initial display is a text box, with a command button "Generate". When the user enters the list type and clicks on the Generate button, the application asks count of elements and gets the elements and finally displays the list."
--------------
I have my code which will generate a random string using an ArrayList. However, I aso want to have it generate them in random lengths, not just using all the chars and numbers.
I am currently concentrating on Java programming skills. Right now developing a Energy usecase in Java with Spring framework. Have business requirement to generate data along with outliers. For example, have two parameters called as min and max (centigrates). Generate a file between min and max and store in a file. Atleast need to generate 10 outliers in each 100 records. Outliers should be < min and > max. How to write a java class with this business condition. The file should be like,
Java Code:
Public class DataGeneration(int min, int max) where min = 30 max = 50
Basic console java program. I need to generate an employee id. I have an employee class that I will paste here so you can see my fields and constructors.
public class Employee { private String firstName; private String lastName; private int id; public int nextUniqueId = 0; public Scanner sc = new Scanner(System.in);
Instruction: You work for a telemarketing company and you are required to write a JAVA program that will generate a random phone number. (talk about a real-world application)
-The phone number should consist of 10 digits -The first 3 are the area code and should not begin with 0, 8 or 9 -The second 3 digits should not be greater than 742 and not less than 100. -The last 4 digits can be any digits -Print the number using the following format: "(xxx)-xxx-xxxx", this way it will look like a real phone number (use decimal formatting)
by this : Generating Random Numbers Using arithmetic operations
I'm doing a project with very defined requirements. Input and output will be done to and from a file. Both the input and output files should have the same format. Each file will consist of a series of lines formatted as follows:
Year Rank Artist Title
That is, each line of the file will consist of the year, rank, artist, and title of a single song, with each of the fields separated by tabs ( ). Output files must maintain this format—you should be able to use the output file of one run of the program as the input to another run.
The first part of my project is to make a Song class, with 6 methods:
public static Song parse(String s) { //Parse a string of the form “Year Rank Artist Title” and create a Song object with the given values. } public int getYear() { //returns the year of the song } public int getRank() { //returns the rank of the song
[Code] .....
So far, I have worked out my Song class like this:
Java Code:
import java.util.Scanner; public class Song { private int year; private int rank; private String artist; private String title;
[Code] ....
I know there's definitely a problem with my parsing, as I am getting the
Exception in thread "main" java.util.NoSuchElementException
when I attempt to input a test String at my variables.
Should I try using StringTokenizer and Integer.parseInt()? I think that perhaps the reason why an error is occuring is because the String is being parsed into Strings and there are no int values to be inputted into the year and rank variables.
I just started programming yesterday, and I have been making little programs to learn some algorithms and the syntax of java. I tried making a program that could convert metric units into the American system. Whenever I try to compile the code, it shows up as an "incompatible type" error. I know this is probably a very obvious answer to most of you, but I can't figure it out.
import java.util.Scanner; public class MetricToAmerican { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("fWhat measurement would you like to convert into US system? celsius, meter, or kilogram ");
the program does not print the list when i select choice 3 it only prints the original 2 elements, same happens if i use if else statements instead of switch statement. Quote public class linklistdemo{
public static void main(String args[]){ while(true) { System.out.println("press one enter element");
I have been working on this Java Gui program and i cant get it to print to the textbox correctly.i originally had it displayed in a dialog window but it would print one integer a time in a seperate window.
I am working on a contact list program with a GUI for a school project.I'm running into all kinds of issues when trying to update the JList in my GUI which displays the contacts.I think my issues are being caused by a lack of synchronization between the contact list that stores the data, and the contact list that is being displayed.I've tried all kinds of getters and setters, passing array indexes, passing array member objects etc.
General rundown of how I want the GUI/Code to work: When I select an object in the JLIst, the fields on the right should display that objects information.When the "Add Contact" button is created, a new blank contact should be created and added to the Contact List, and then displayed in the JList.When a field on the right side of the GUI is updated, the object in the contact list is updated simultaneously (using document listener), and therefore the JList would also be updated.
read a text file that has some polynomials in a specific format and perform an arithmetic expression. This needs to be done using a singly-linked list to store the coefficients of the polynomials. There needs to be two methods, one that adds the two polynomials and one to multiply them. So for example suppose i had the following set of polynomials in the text file:
2+x2-3x3 and 1-x-2x2+3x3
these are represented by 2, 0, 1, -3 and 1, -1, -2, 3 respectively. The of the two polynomials is: 3-x-x2 which is represented as: 3, -1, -1
The product of the two polynomials is: 2-2x-3x2+2x3+x4+9x5-9x6
My code is just echoing the data in the text file and not actually doing any arithmetic.
import java.io.*; import java.util.Scanner; class Node { public int digi1; public int digi2; public Node nxt;
I am trying to write a java program that asks the user for a list of names (one per line) until the user enters a blank line. At that point the program should print out the list of names entered, where each name is listed only once (i.e., uniquely) no matter how many times the user entered the name in the program. I am supposed to use an ArrayList for this problem.
My idea for a solution is to create an ArrayList<String>, read each name, i.e., line, entered and then to see if that name is already in the ArrayList. I created a for loop to check each element in the ArrayList but when I try to assign an element to a string variable I get the error "Type mismatch: cannot convert from Object to String". Not sure why that is happening because the ArrayList is defined as a String list.
I am stuck on what to put in my functions for this question: Write a program to maintain a list of the high scores obtained in a game. The program should first ask the user how many scores they want to maintain and then repeatedly accept new scores from the user and should add the score to the list of high scores (in the appropriate position) if it is higher than any of the existing high scores. You must include the following functions:
-initialiseHighScores () which sets all high scores to zero.
-printHighScores() which prints the high scores in the format: "The high scores are 345, 300, 234", for all exisiting high scores in the list (remember that sometimes it won't be full).
-higherThan() which takes the high scores and a new score and returns whether the passed score is higher than any of those in the high score list.
-insertScore() which takes the current high score list and a new score and updates it by inserting the new score at the appropriate position in the list
here are my functions the insertScore is missing because I am having troubles with it.
public static void initialiseHighScores (int[] scores, int size) { for (int i = 0; i < size; i++) { scores [i] = 0; } } public static boolean higherThan (int[] scores, int size, int newScore) {
I'm trying to build a program that contains the ability to:
(1) insert new node at head, (2) print out contents of the list in order, (3) remove first node from head, (4) remove last node from tail, (5) find a target value, (6) give total number of occurrences of a target value, and (7) give total number of items in list.
The areas I'm struggling with implementing are: (
- remove from tail - I know how to find the final node but I can't quite figure out how to set it to null since its initial type is an integer. - find a target value - how to make the parameters quite workout so the user can simply input an integer value. - The solution is probably really simple but I can't figure out how to print out the results of these methods when I call them.
public class Node { private int data; private Node link; // Node Constructor 1 public Node() { data = 0; link = null;
I want to create java program in which i want to inherit stack and queue from a linked list class and also make infix to postfix inherit from stack and periority queue from queue class.Ho can i make this program.
Write a java program to store employee information in a linked list, the program should implement the following functions:
The program should display the list of functions, and ask the user to enter the number of function that he/she wants to do, then perform the function as it is required in the previous table.
import java.util.*; public class Employee { Scanner in = new Scanner(System.in); String Name; String Address; String Department; int ID; int Salary;
[code]....
this is my out put
Please choose a number: 1-Add a new employee 2-Update employee's info 3-Remove employee's info 4-Exit 1 Enter name: Enter address: 2 Enter department: 3 Enter ID: 4 Enter salary:
now:
1- why are not my adding coming out in the output only the Enter name & Enter address ??
2- how can I add names and ID's and information to test that program
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;
I have some class called sorted to sort the linked list through the nodes of the list. and other class to test this ability, i made object of the sort class called "list1" and insert the values to the linked list.
If i make other object called "list2" and want to merge those two lists by using method merge in sort class. And wrote code of
list1.merge(list2);
How can the merge method in sort class know the values of list1 that called it as this object is created in other class.
I have a list of 100,000 + names and I need to append to that list another 100,000 names. Each name must be unique. Currently I iterate through the entire list to be sure the name does not exist. As you can imagine this is very slow. I am new to Java and I am maintaining a 15+ year old product. Is there a better way to check for an existing name?
I receive a java.lang.NumberFormatException: For input string: ""DepDelayMinutes"" error when trying to filter a list and then assign the results to a new list.
I have edited the code so it is an int that throws the exception so it isn't the presence of a string that is causing the error - java.lang.NumberFormatException: For input string: ""0914"" .
I believe the issue is because of the two sets of double quotes but I do not understand how they came about. The original dataset does not have any quotes whatsoever.
Suppose i have given a List<Intervals> list; I am iterating over list and inserting each element from list into BST, if time require to insert into BST is logn then what is the total time require to insert all the elements into tree ?
So we have an assignment regarding a linked list implementation of a given list interface.
In my list interface, the method contains(T anEntry) is defined.
In the LList implementation, contains is already implemented as part of getting the core methods in.
Now I am being tasked with the following:
Provide a second implementation of the method contains2(T anEntry) that calls a private recursive method
Private boolean contains (T anEntry, Node startNode) that returns whether the list that starts at startNode contains the entry anEntry.
I've written the private recursive method already. That's not an issue (at least not right now).
But what I don't understand is how startNode is supposed to be populated when this private contains method is called from the public contains2 method? contains2 only takes one parameter: anEntry. the private method takes two parameters: anEntry and startNode. How am i supposed to provide startNode when I am calling contains2?
"which code is best for randomly generating integer 0 or 1". Haven't gotten my grade back yet but in reading these during the test I didn't think any of these would kick out both of those numbers, but there was no "none of the above" option on the test.This is exactly how it appeared on the test:
A) (int)Math.random() + 1 B) (int)(Math.random() + 0.2) C) (int)Math.random() D) (int)(Math.random() + 0.8) E) (int)(Math.random() + 0.5)
I've tried all of them in the cs lab 100 times each and none of them generated both numbers. 'A' kicked out 1 every time. 'B,D and E' kicked out 0.2, 0.8 and 0.5 respectively each time, and 'C' kicked out 0. Did I just not run them enough times for the result to change or am I right in thinking there's a glitch on the test?
I have a large product with many maven projects, all of which can be hierarchically tracked back to the same parent. The projects have javadocs and whatnot.
Icommand line instructions (Windows 7) to generate the full API documents html on my local machine (of all the projects together). If there is a maven command for doing this from the CMD, more the better.
I need to generate a bar chart given the data that is in main. The relative performance of each sorting algorithm with respect to time, number of comparisons, and number of swaps for each data set (e.g., 50,000 –400,000 random integers). Each algorithm will have 5 bars corresponding to the 5 data sets. The height of these bars will depend on the performance of the algorithm for that data set.
I know how to write a bar with normal values like integers but for this I'm not sure because the values for instance comparisons and swaps are not given they are calculated. I just need to know what steps to go about doing that, you can even express them in pseudocode or even just explaining it I don't need the code, I think. Here is the main
public class Main { public static void main(String[] args){ int t= 50000; int t2=100000; int t3=200000; int t4=300000; int t5=400000;