I have a problem with my code. It gives me the error I put as title:
backgroundA.setOnClickListener(new View.OnClickListener(){ public void onClick(View view){ if (j < 2){ int randomInt1 = random1.nextInt(Deck.length()); int drawableIDA = Deck.getResourceId(randomInt1, -1);
[Code] ....
This error is in the first line and I have also one in the last, where eclipse looking for a @ (O.o). Also I will insert the variable choice1.
final Button choice1 = (Button) findViewById(R.id.A);
When do you get the error <identifier> expected? I've written a small application where input is accepted by a textfield and based on some condition a dialog should be displayed saying "invalid i/p". But am not able to correct ths particular error ....
I created a superclass Ships and under that a class CivilShips. Under that HumanBulkFreighter.
I declared variables in Ships and CivilShips and wanted to have them set in HBF to a specific value. When I know try to compile them I get the following:
This is what i have so far, I use BlueJay to write this:
import javax.swing.JOptionPane; public class payroll { String again = y; // private String name; private double rate; private double hours; static double gross; //gross pay
[code]....
my first problem is that it expects a ")" on this line :"if ((hours <=40)rate *1);"For the assignment itself these are the requirements:
-Create a class called payroll with private variables for rate hours and name
-Create static variables for gross pay, union dues, health coverage (hp in my case), FICA taxes, State taxes, Federal taxes, net pay, all must be initialized to 0
-default constructor that assigns default values
a function called calcPay that will do the following tasks and print it to a pay stub :
- function that checks the hours ( if hours are 40 or less pay rate, if over 40 pay 150% of the rate) - calculates gross pay before any deductions (using user inputted hours and rate) - deduct medical coverage and union dues from gross pay and call this adjusted gross pay (also this should have its own line on the paystub) - A function that deducts State, federal and fica taxes from adjusted gross - FICA - 7% for any income -Federal - 2% for $0-$150 / 6% for 150.01 - 300 / 14% for 300.01 - 600 / 18% for 600.01 - unlimited -State - 1% for 0-150/ 3% 150.01 - 300 / 5% 300.01 - 600/ 8% 600.01 - unlimited - amount after all deductions is the net pay ( show this amount on its own line) - Start a loop that asks each time if there are more employees (y/n) y should continue the program and n should end it -dialog boxes should be created to recieve values for name, hours and rate - if the rate is entered below $8 dollars a new box should pop up and ask for a higher value - When there are no more employees, print out a summary of quantities stored in static variable (also had a problem with this) - End
So I think i completed most of these objectives but am having trouble with the syntax and some of the objectives
So my only error in the entire code is on the 9th line of this code sample. It says "Syntax Error on token "new", @ expected" but @ does not belong there, as far as I can tell, since the error does not go away upon adding it.
public class Obstapacalypse implements KeyListener, ActionListener { private static final String EXIT_ON_CLOSE = null; private JFrame frame; private Player player = new Player(); private JPanel contentPane; private JButton btnStart;
Need to write two files but getting an expected exception error.
import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.Scanner; import java.io.FileWriter; public class TestingPanel extends JPanel
[Code] ....
TestingPanel.java:49: error: unreported exception IOException; must be caught or declared to be thrown FileWriter outputFileQuestions = new FileWriter("Test.txt"); ^ TestingPanel.java:50: error: unreported exception IOException; must be caught or declared to be thrown FileWriter outputFileAnswers = new FileWriter("Answers.txt");
My issue is that when I run the code if I enter anything but 1, 2, or 3 the code breaks. I have spent hours trying to find the error. here is my code
import java.util.Scanner; public class Tester { public static void main(String[] args) { /** * constructor * pre: none * post: inherit values of other classes */ Car Car = new Car(); //inherits the properties of the Car class Truck Truck = new Truck(); //inherits the properties of the Truck class
I'm not sure why I'm getting these errors. They only begin to happen after the second if statement, and the subsequent if statements are formatted exactly the same.
The errors are marked by the comments in the code.
Java Code:
import java.util.*; import java.io.*; public class GazillionSongs { public static void main(String[] args) throws FileNotFoundException { System.out.println("Welcome to Java Song Collection!"); System.out .println("This program sorts and filters large databases of popular songs.");
My if else statement is not working...it keeps telling me that the else in the statement is a syntax error and that I should remove it. Whats wrong with it?
package Homework2; import java.util.Scanner; public class Homework2 { public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("Welcome to the Triangle Program.");
I am currently working on modules of a java program but am having issues with this module . it gives this error code"syntax error on token '?', invalid primitive type".
this is a syntax error within Jasper reports in the printwhenexpression property.I can use the following expression successfully: new Boolean ($F{off_peak_free_minutes}. trim().equals("")==false) - this basically tells Jasper Reports to ignore the column unless it has a value.
Now I'm trying to do the same thing with ZERO but I can't get the syntax right. I've tried: new Boolean($F{off_peak_free_minutes} != 0) but the ZERO comes up with a red underline implying that this is illegal.I've also tried: new Boolean($F{friends_family_minutes}!=Double.valueOf(0)) but the ZERO comes up with the red underline.
I suspect I'm just not specifying the JAVA right. I believe that the $F{friends_family_minutes} variable is a DOUBLE - it prints as 0.00 on the report.
Multiple markers at this line - void is an invalid type for the variable loadDictionaryFromFile - Syntax error on token ")", ; expected - Syntax error on token "(", ; expected
Line 13 starts public void load....
Code:
import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.Scanner; public class PirateTranslator { public static void main(String[] args)
Netbeans do not detect any syntax errors, but I when I check the build it retuned areas they were a few; It's a simple program name 5 people, gade them then do final calulatoins it's called "grade tool.
heres the code
package gradingapplication; import java.util.Scanner; public class GradingApplication { public static double score(double score){ if(score >= 90){ System.out.println("A");
[code]...
~Problems~
1. It has no gui, I don't know java fx, is java groove used? awt is useful for creating spam bots in robot class, I know it's not very useful but it's so much fun.
I am trying to insert a record to a table in my database . I used the same syntax for 2 tables, one does work and the other does not work . I could not find any explanation for this error
"INSERT INTO CustomerRecord (Name, Number, Adress)" +" VALUES(?,?,?)"; //first table working well ps.setString(1,r.getCustomerName()); ps.setString(2,r.getCustomerNumber());
[Code] ....
For some reason one does work but the other does not work it says syntax error near order (table name). I am using sqlite db ...
I am trying to make lexical phase of compiler. But when I try to add character (after validating them, whether they are character or not) to token array I cannot do it.
public class Main { static int counter; static char ch[]; static char c; static char token[]; static String read;
how do i get the inputed strings to print out after i turn them into tokens ? I need it to ask for a number and then multiple lines of strings, turn them into tokens, then print them out.
import java.util.*; public class TokenDriver{ public static void main(String [] args){ // TokenStore words = new TokenStore(); String[] tokens = new String[300];
[code].....
also as a follow up how would use an array in an other class (TokenStore) to save the typed line information
I am trying to read a text file into Java and split the text into tokens. Eventually I want to be able to count the number of instances of a specific word. However, at this point, when I run the file, all I get is the location of the file rather than the text in the file.
import java.util.*; import java.io.*; public class textTest3 { /** * Prints the number of words in a given file * * @param args * @throws IOException */
the problem which im facing when executing jar file is it is not working same as when i run file using the IDE.When run jar file, it won't open the new frame even the user and pass combination correct.But when i'm compiling using the IDE, it works as charm. The main menu popped up after i logged in.I've tried Clean and Build and it's not working too.
I am trying to get a scrollPane working correctly, but not having any luck. The picture drawn in the center panel is quite large and goes off the screen. I visited URL... but I am missing something vital. Both tracks show, but there is no knob to do the scrolling.
public DViewer() { super(); frame = new JFrame(); frame.setSize(Toolkit.getDefaultToolkit().getScreenSize()); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);