The parameter for the starting y is "fy" (Half of the screen). When I use the keys "z" and "x" it translates one pixel at a time left and right. That is good, but when I use the keys "a" and "s" it will double each time (good), but the starting y will drop significantly (bad). I tried manipulating the "x" and "fy" variables, but to no avail.
I was told to create a class named Billing that includes three overloaded computeBill methods for a photobook store.
The first method takes the price of the book ordered, adds 8% tax and returns the total due. The second method takes the price of the book, and the quantity, adds tax and returns the total. The final method takes the price, quantity and a coupon discount, adds tax and returns the total.
All of this I have managed fairly well, although I keep getting a strange error at the end of my program that the constructor is undefined. The problem bits of code(the one throwing the errors) are under the comment //Enter values into each of the methods
Code:
package org.CIS406.lab2;
public class Billing { //Declarations double bookPrice; int quantityOrdered; double couponValue;
[Code] ....
My first thought was to create a constructor for each of the methods that I am using...
I am creating a program for rational numbers but it does not work properly when I enter a negative number in the denominator. It works with every other number.
import java.io.*; import java.util.Scanner; public class RationalNumber { private int numerator; private int denominator;
I am new to JMS and Websphere server and I am trying to access a JMS queue configured on Websphere Application Server 8 from my Java code. But I am getting the exception mentioned below:
Exception in thread "main" java.lang.NoClassDefFoundError: com.ibm.ws.naming.util.CommonHelpers at com.ibm.websphere.naming.WsnInitialContextFactory.getInitialContext(Unknown Source) at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:230) at javax.naming.InitialContext.initializeDefaultInitCtx(InitialContext.java:313) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:343) at javax.naming.InitialContext.internalInit(InitialContext.java:281)
I am writing a code that tries to figure out the users password by going through every possible key (brute force). Although I think its going to work, it looks EXTREMELY inefficient to me, since its just a huge switch statement for each character -- 94 total, including the shift values. Is there a built in method in the JAVA API that goes through every key or something?
Here is my code for that segment:
public char[] HackingPassword(){ char[] passChars = this.password.toCharArray();//convert the password to char[] char[] hacking = new char[passChars.length];//make the hacking variable same size as users password int nextCharValue = 0;//this is used to cycle through the keyboard //check each letter of hacking to match with password for(int i = 0; i < passChars.length; i++){
I created a scanner object but it's not asking for any input. when I create a new scanner and then tell it to print it it just prints a bunch of weirdness when AFIK it should be asking me to type something and then it should repeat what i entered.
Write a program that extracts words from a file. For the purposes of this program, a word is defined as a series of adjacent letters. Only print words that are at least four and no more than 12 letters long. Print each word on a different line.
The program should read the name of the file from the keyboard.
I need to get the filename from the user for this particular program. Usually I would have the name of the file prewritten into the source code like this....
Scanner input = new Scanner(new File("gettsy_burg.txt");
I tried different ways but I just can't seem to figure it out.... I guess what I'm really asking is how to rearrange Scanner input = new Scanner(new File("gettsy_burg.txt"); since I want the user to input the filename instead of the filename being prewritten by the programmer(me).
This is what I have so far to let the user for input....
Scanner keys = new Scanner(System.in); System.out.println("Enter the filename: "); String fileName = keys.nextLine(); keys = new Scanner(new File(fileName));
Write a program that extracts words from a file. For the purposes of this program, a word is defined as a series of adjacent letters. Only print words that are at least four and no more than 12 letters long. Print each word on a different line.
The program should read the name of the file from the keyboard.
I need to get the filename from the user for this particular program. Usually I would have the name of the file prewritten into the source code like this....
Scanner input = new Scanner(new File("gettsy_burg.txt");
I tried different ways but I just can't seem to figure it out....
I wanted to make a small program to move a small rectangle by pressing the WASD keys. The program works, except that when I hold a key to move the rectangle, after a second, auto-repeat starts up, and the rectangle motion accelerates. I want to prevent automatic repeat to activate, so that the rectangle moves at a constant speed when I hold a key and stops when I released. Here is the ButtonMotion classe :
I wanted to create a simple window with the LWJGL and a key input request which closes the window.I also wanted to create the classes in seperated packages, so it's more organized.The window displays but if I press that certain key nothing happens.Here is the Main class:
package bb.main; import bb.input.Input; import bb.main.render.SimpleRenderer; public class Main { public static void main(String[] args){ SimpleRenderer createWindow = new SimpleRenderer(); Inputinput= new Input();
so i'm working in a chat program and i'm trying to make it so that you are able to open another tab yet still be able to chat.
right now the client that the user download uses the keyadapter to get the keyboard input, but whenever the user un-focus the chat window, the keyadapter no longer gets the keyboard input.so is there another way i can get the keyboard input? so it doesn't matter what window you are focused on, you get the keyboard input either way?
The program runs well , it adds the applet but it dosn't update the interface unless I press "_"(Minimize) . To be more clear , the object paints a spring wich goes through 4 stages , it is added to the JFrame but it dosn't uptade until I minimize the frame , that is when it goes to the next stage .
The main class which calls the spring to be added to the frame :
public class principal implements ActionListener ,Runnable{ JTextField field; JFrame frame; private class Action implements ActionListener { public void actionPerformed(ActionEvent event) { frame.repaint();
When I long click item in the list nothing happens. I get no errors at all and I believe that either I put the code in the wrong place or I missed something else that stops Dialog from starting.
my validAccounts array will not fill properly and has a null value in it.I added a print statement that prints the contents of the array and it is filling correctly but the very last value is null. I am supposed to be asking the user for a account number and password and it is not printing out correctly due to the fact that the array is not filled correctly.
import java.util.*; import java.io.*; public class ATM2 { public static Scanner kbd; public static final int MAXSIZE = 50002;
My question is to evaluate a Postfix notation entered from keyboard. I have no errors in my code but it prints only :
Exception in thread "main"
java.util.NoSuchElementException at ArrayStack.pop(PostFixEvaluation.java:72) at PostFixEvaluation.evaluatePostfix(PostFixEvaluatio n.java:107) at PostFixEvaluation.main(PostFixEvaluation.java:140)
I tried many values but it prints the same exception all the time.
I am trying to create this program I am pretty sure it is easy but I am making it difficult lol, it keeps giving me a error, it is saying cannot find symbol - variable keyboard, I don't think I have keyboard as a variable but I may be wrong.
double distancel = keyboard.nextdouble(); that is the specific line ....
import javax.swing.JOptionPane; import java.io.File; import java.util.Scanner; //import java.util.totalInches; //instance variables public class Map{ public static void main(String[] args){