I am working on implementing a stack using a linked list. Programming the stack operations (push, pop, isEmpty, etc.) was easy but my directions were to provide the user with a menu to choose the operation that he/she wishes to perform. I am new to JFrames/Menus so how to make the stack operations available in a menu.
I have having some trouble on counting the primitive operations on the pseudocode given below:
Algorithm 4. MaximumArray(Arr) Input: A 1-D numerical array Arr of size n 1) Let CurrentMax = a0 2) For i = 1 to n-1 3)If ai > CurrentMax Then CurrentMax = ai 4) End For Output: CurrentMax, the largest value in Arr
As of now, I know that for Line 1 there are 2 operations (one set and one read). I don't know how to figure out the for loop and If statement (line 2 and line 3 too).
I've been wondering about this for a while. Is there any way to parallel I/O operations or is this a bad idea? If you could create two lists of good and bad ways to parallelize I/O.
This is what I have so far, but I don't know how to continue:
import java.util.Scanner; public class ArithmeticComputation{ public static void main(String[] args) { Scanner stdin = new Scanner(System.in); int num1 = stdin.nextInt();
[Code] ....
I'm looking for a method that allows me to assign char into actual operators, so that I can loop through all the computation.
Given a LISP expression, perform operations on the expression. There will be no list elements that also contain a list such as '(A (B (C D))), which has one atom and one list but the list contains a sublist
INPUT: There will be 5 lines of input. Each line will contain a valid LISP expression. There will be a space between each atom and each list. There are no spaces immediately after or immediately before parentheses in a list. The entire expression must be inputted as a single string.
OUPUT: Perform the given operation on the like numbered expression. The 5 operations are:
1. Print the expression with the list in reverse order. The list will contain only atoms.
2. Print the expression with the list written with consecutive duplicates encoded as sublists in (count element) order. The list will contain only atoms.
3 Print the expression with the list written with consecutive duplicates encoded as sublists in (count element) order except that singletons are listed as atoms. The list will contain only atoms.
4. Print the expression with the list written with every Nth element deleted and where N is the last element of the list.
5. Print the expression written as 2 expressions where the number of lists in first expression is the last element of the expression.
SAMPLE INPUT SAMPLE OUTPUT 1. '(A B C D) 1. ′(D C B A) 2. '(A A A A B C C A A D E E E E) 2. ′((4 A) (1 B) (2 C) (2 A) (1 D) (4 E)) 3. '(A A A A B C C A A D E E E E) 3. ′((4 A) B (2 C) (2 A) D (4 E)) 4. '((4 A) (1 B) (2 C) (2 A) (1 D) (4 E) 2) 4. ′((4 A) (2 C) (1 D) 2) 5. '((4 A) (1 B) (2 C) (2 A) (1 D) (4 E) 3) 5. ′((4 A) (1 B) (2 C)) ′((2 A) (1 D) (4 E) 3)
String filename="C:UsersRajashekarDesktopfwfwdSoftware Failures1_Test.txt";//Input Files String data; public ArrayList<String> value=new ArrayList<String>(); public void read() throws IOException{ File f = new File(filename);
I have read that when two threads have two steps (of execution) and each step involves many operations, then the operations of both the threads kind of overlap one-another. For example
I think I am not very clear about interleaving actions/operations? Especially when we say that atomic actions can not be interleaved. But
Java Code:
class Counter{ private int c=0; void increment () { c++; } void readIn () {
[Code] ....
And the following sequence of events occurs.
Thread A: Retrieve cThread A: Increment cThread A: Store the result in cThread B: Ask the user to enter a valueThread B: Read in the value, store it in c
Now the value of c obtained after increment will be lost (Thread Interference). Isn't this an example of interleaving operations?
I want a simple jsp page that performs basic operations on numbers such as addition, subtraction, multiplication, division and modulus . How to run that file?
i've spend an hour or two, pasting fragments from tutorials and nothing changed.
Well - i have GUI, that have JComboBox with two elements: String[] fedoras = { "Fedora 19", "Fedora 20" }; JComboBox fedora_list = new JComboBox(fedoras); fedora_list.setSelectedIndex(0); fedora_list.setBounds(120,170, 170,25); fedora_list.addActionListener(this); this.add(fedora_list);
Below i have normal button (named Update) with "update" set as ActionCommand. This button after clicked should check which value from list is selected and perform different operations for that elements. But it's harder than i thought.
Code for update button:
public void actionPerformed(ActionEvent e){ String cmd = e.getActionCommand(); (...) else if ("update".equals(cmd)){ String selectedFedora = (String) fedora_list.getSelectedItem(); if (selectedFedora.equals("Fedora 19")) {
[code]....
- after user clicked Update button, button should check which value is selected in JComboBox (fedora_list). - if Fedora 19 is selected and button clicked, then action in Xterm - if Fedora 20 is selected, this same action in Xterm is performed, but for Fedora Linux 20
The problem is - i don't know hot to code Update button to check which value from fedora_list (JComboBox) is selected and perform other actions for every element on List.
How can i write a java program that simulate a simple calculator that performs the basic arithmetic operations of JAVA. (JOption Pane and Repeat control structure)
Example : Addition, Subtraction, Multiplication, Division.
The program will prompt to input two floating point numbers and a character that represents the operations presented above. In the event that the operator input is valid, prompt the user to input the operator again.
I want to create a dropdown menu with contents from a database. You can see my Code in the attachment. It does not work, but why? I have a dropdown-symbol, but no contents.
I have a GUI with a menu to do various options. However I want to change that menu to use buttons instead. I'm working with JSwing components and I'm a little familiar with the JButton function, but I don't know how to convert the menu to a button. I think I'll have to remove the menu completely..anyway I tried to start with the file menu but the compiler says no suitable method found for setForeground(javax.swing.JMenu). Why is it giving me an error related to JMenu when I'm using Jbutton objects? Can I not use JButton objects inside a menubar scope? I'll bold the area it highlighted:
ok so I am trying to create a movie rental database. I want to show a list of movies, customers, and rentals. my problem is that I cant run everything but I keep getting the following error :
ERROR: Table/View 'MOVIES' does not exist.
Here is my code
import java.sql.*; import java.util.Scanner; public class MovieRentalDB { public static void main(String[] args)
[code]....
the program runs but I keep getting that error. I know my code is also not complete but I will do the rest once I figure out why my tables are not creating
I am making an edit page and I want to populate my drop down menu with things that were already selected. For example, if i want i click to edit my favorite food it will be populated with the one the user previously selected. How do i go about doing this? [URL] ....
How do I code this so that after the user has added to the arraylist 'theFruit' if they then press 'V' to view all fruit it includes the default fruit as well as the fruit they've added?
Also in the method 'AddFruit' it only allows me to add 2 fruit before printing. Why is this?
import java.util.ArrayList; import java.util.Scanner; public class StkOv { public static void main(String[] args) { TheMenu();
I cannot use menu selection 4 5 6 7 8 9 10 ... Why NO_EXIT has been declared and used in defining the contents of the map array, rather than just directly using the value 99999 in the map array definition
I don't understand map[][], objectName[] and objectLocation[]
package Assignment; import java.util.Scanner; public class GameWorld { // the map array holds details on which paths lead to which other rooms. NO_EXIT indicates no valid exit. // each element holds the details of all paths leading out from a single-room in the order n ,e, s, w, ne, se, sw, nw private final int NO_EXIT = 99999; // indicates that there is no exit in that direction private int map[][] ={{NO_EXIT,NO_EXIT,NO_EXIT,1},{2,0,NO_EXIT,NO_EXIT},{NO_EXIT,3,1,NO_EXIT},{NO_EXIT,NO_EXIT,NO_EXIT,2}};