import javax.swing.*; import java.awt.MenuBar; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class NewCalculator implements ActionListener { //assign button clicked number and answer onto variables.
[Code] .....
Also what is the code I need to use to do the percentage and square root calculation in the calculation. Cos I am not sure about the sign I am required to use to do the calculation.
The if statement is where the code to make the clear button (C and CE) work.
I want to make a calculator program as my first ever program and I've been working on the layout and I think I have it close to where I want it but will probably tweak it in the future after I get it to work. My problem is I'm trying to add a MenuBar to it but it is not showing up. I tried having it all over my code but whereever I put it the MenuBar doesn't show up.
I've got my clear button to work on most of the stuff I want, however I cant figure out how to fix the price to stop adding up. e.g. hit a button image with a price of 599.99, hit the clear button to empty, select price of 599.99 again then it display 1199.98.
I'm back with a question about the Black Jack assignment. I've created a working game that works for one round, as well as a reset button that's able to clear the board of the old hand. However the runGame() loop, which checks whether a player has played his hand seems to freeze the program the second time around
private void initNewGame(){ dealer.addCard(); for(int i = 0; i < numberofplayers; i++){ players[i].addCard(); //draws card, adds score and paints card to the board players[i].setStatus(false); //makes the buttons usable in the players[] class
[Code] .....
I know it's probably not optimal having an while loop constantly running to check the status, but I can't seem to figure out why it freezes.
I've beginning a new assignment and would like some feedback on my outline for the program. You are to design a simple calculator using the stack data structure to perform additions, subtractions, multiplications and divisions. The user may enter an arithmetic expression in infix using numbers, parentheses and arithmetic operations (+, -, *, /). After an expression is entered, its postfix or prefix notation is displayed and then the result of the expression. You are required to design your own infix to postfix and infix to prefix conversions.
The professors example includes: SinglyLinkedList implementation, a Stack that implements Stack interface and extends SinglyLinkedList, a Node class, and StackApp -- in addition to the main class and the prefix/post-fix classes.
(The equation is entered/stored as a string variable) System.out.println("Enter equation: "); equation = input.next(); equation.trim();
(1.) Get the user input: - evaluate the user input and use a stack to determine the correct prefix/post-fix notation. - from the stack, pop each item: a. account for '(' and ')' to push all operators and write all operands until ')', then pop/write b. store new equation into a list (in prefix/postfix notation)
(2.) Display the list in both notations to the user.
(3.) Perform the calculation.Do you think it will be alright to calculate the original equation that was entered? It seems too much to then design a class that will then cycle through the polish notation and calculate according to that format.
My assignment is to essentially update a calculator program that uses strings, and methods, to include arrays. How to create and call an array that the user defines the size of and then inputs the numbers to fill the array. Here's the example my prof gave us of what the output should look like:
Menu 1. Add 2. Subtract 3. Multiply 4. Divide 5. Dot product 6. Generate random array 7. Quit
What would you like to do? 1
How many values are in the arrays? 3
Enter the values in the first array, separated by spaces: 2 4 6
Enter the values in the second array, separated by spaces: 1 3 5
The result is [3.0, 7.0, 11.0]
How to create an array that would allow the user to define the size of the array and then inputs the values for the array? I'm completely lost. I never should have taken java as an online class.
I'm writing a command line application of a calculator in Java. I need to be able to (as per program requirements) split the array of strings (6+3) into an array of strings? How would that be done? I know you can use the split method, but I am not really sure how that wold work to perform math with them?
On a side note: for this application, how could you make the program accept a variety of different lengths of strings to perform math with them?
My issues is at the bottom, I can't get the clear button to clear, well it clears but it also show the JOptionPane. I couldn't find the edit button on the page
coding the action listener for my button (btBody) which create button displaying 1 to 9 in a nested for loop; the button should allow the user to click on them and to display the number clicked on in a JTextField;my code;
import java.awt.*; import javax.swing.*; import java.awt.event.*; public class EX_7_2 extends JFrame { public EX_7_2() { setLayout(new BorderLayout(5, 10));
Here is my code, basically I'll tell you what my program is suppose to do, I want to be able to leave the text box's empty if I like I want to skip 1 or more or all if I like skipping just basically means 0 but getting this error, it's forcing me to type in them all.
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatException.forInputString(Unk nown Source) at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at StockControl.addToStock(StockControl.java:86)
I could get my session values in my jsp, now I want to compare the session value whether it matches the textbox, if it matches, it will redirect the user to another page else it will remain the same page.
This is my textbox can i include in my tetxbox that it will no accept special characters?
Can i configure it there? like maxlength="20" w/c is character limit is set to 20, not allowing special characters be configure like that , character="speical is not allowed" something like that?
This one is working if i set value in fmt but what i want to happen is when i enter a number in textbox it will be fommated on the format that i want, so i think i need to an of og text and set it into value of fmt? <y plan is when I enter a number in textbox it will automatically formatted ....
I need adding a textbox for users to input text onto my JFRame. Also how come the
frame.add(o);
is getting an error under the "add".
Main method class:
import javax.swing.JFrame; public class main { public static void main(String[] args) { JFrame frame = new JFrame(); bot o = new bot();
[Code] ......
Other class (this is where I want the textbox to be)
import javax.swing.JTextArea; import javax.swing.JTextField; public class bot { int x; int y; JTextField f = new JTextField(); JTextArea a = new JTextArea(30, 50); }
- The Instance Text box and SAVE button should be disabled. When the pop up appears. - The Instance Text BOX gets enabled only when any selection happenes in COMBO Box - The SAVE button gets enabled only when COMBO BOX and INSTANCE TEXT BOX is filled. - Let the CANCEL button be enabled always.
I am having an array of strings and i want to find out whether these strings contained in the array contain a similar character or not.For example i am having following strings in the array of string:
aadafbd dsfgdfbvc sdfgyub fhjgbjhjd
my program should provide following result: 3 because i have 3 characters which are similar in all the strings of the array(f,b,d).
I can sort strings in a collection by uppercase and then lowercase though I was wondering if there is any way of doing it in reverse, sorting by lowercase then by uppercase.
I have a code that clear old text then add new text to text file afterthat download the file but the problem my code dose not add new text
FileInputStream fileToDownload ; private static final int BYTES_DOWNLOAD = 1024; response.setContentType("text/plain"); String name = request.getParameter("n"); String text = new String(request.getParameter("text").getBytes("iso-8859-1"), "UTF-8");
[Code] ....
How to clear old text then add new text to text file
Follow the //? FIRST and SECOND notes, then I understood that Java has GOTO as Keyword for future versions and that usually one can avoid GOTO using break inside the cycles, but I need a jump( salto) in the code.
import java.util.Scanner; public class ArrayOrdinati { public static void main (String[] args){ int[] Array = {5,3,1}; int e=Array.length; int b;