I was wondering if you use an IDE when writing programs?Can you use J frame when using command line or is it just used with an IDE and do you go into framing in the book?I have taken programming classes and I am still stuck.
I'd like to make a simple cheat for an old game that's offline... It has no type of anti-cheat and I'd like to make a program that changes how much money you have... I think the first thing I have to do is get the data address or something like that by using cheat engine... How do I do that? After that how do I start using that info in my program and then send back a new value? Are there any classes that I should be importing and what methods do I use to do this?
I have a programs to write which is to display only the odd numbers between 1 and 15 and the code i use it is not display what i was expecting it to but instead it looping 15 times and at the end it says that the odd number is 15 or 1. where or what have i entered wrong. it supposed to display only the odd numbers between 1 and 15here is the code that I write.
Scanner input = new Scanner (System.in); int i, num=0, count = 0, count_odd = 0, oddnum = 0; for(i=1; i<=15; i++) { System.out.println("Please enter number"); num = input.nextInt(); }
Whenever I make something in Swing, I always need to resize the window for me to see the graphics on the window. I have been told to use the pack() method on it, which I have, but the problem with it is that it just sets the window to a minimal size, only displaying the x + and -.For one of the "games" I made, it at first didn't work until resize, then I added a repaint() after the constructor and it worked for me, but when my friends download it they cannot see it.
I've been playing around with this for about an hour.
Java Code:
Runtime runTime = Runtime.getRuntime(); try { Process process = runTime.exec("notepad"); } catch (IOException e) { e.printStackTrace(); } mh_sh_highlight_all('java'); So that works. Notepad will open.
However, I'm trying to get other programs to open. Specifically, this program: C:Octave3.2.4_gcc-4.4.0inoctave-3.2.4.exe...However, using that in place of notepad doesn't work. I'm assuming that there is some sort of system variable that explains why simply typing "notepad" works? As if you type notepad into the run box, notepad will open. Soo does that snippet work by going through some sort of system variables?How would I go about opening other programs, such as the one I referenced above.
how to structure simple programs (i.e. one-method algorithms for a simple purpose). There are a few different ways that I have been doing it, but I want to be consistent. Should I put both the one-method algorithm (e.g. a factorial function) and the main method that executes the algorithm into the same class and then export it to an executable .jar file for use? Or should I create one class for the algorithm and another for the main method that executes the algorithm? In addition, is there any reason that I should out these classes in a package before I export it?
As another similar question, if I have constructed two distinct classes with two separate purposes, and they are both used in the construction of a single program, then would it be best to just put the main method in a third, separate class or should I put it in one of the two classes?
My PC runs on Windows XP. When I try to run a java program (written using NetBeans) from the command prompt, the program opens in NotePad but does not run.This is what I have been typing at the command prompt:
C:javahellosrchelloHello.java
The above is the correct path to the Java file on my PC.how to run the program from the command prompt or perhaps link me to a tutorial that explains it?
I have copied a wav file as explained in [URL] ..... When trying to play my new file, it runs but no sound is hear. My reading and writing class is as explained in another post in the site:
This is the function that reads the file:
// read a wav file into this class public boolean read(DataInputStream inFile) { myData = null; byte[] tmpInt = new byte[4]; byte[] tmpShort = new byte[2];
[Code] ....
I can't hear the copied wav file, but still the wav file is correctly copied...
I am writing a program in Java where a user adds 1 stamp on a letter for every five sheets of paper in it (or fraction thereof)For example, I if I have 11 sheets of paper, I add 3 stamps. If the total number of stamps is more than 3, they don't send it.
I need to ask the user how many sheets of paper they have, and then calculate the appropriate number of stamps based on the formula above. I just don't know how to write the math formula to calculate this, i'm stuck. So far I have:
package test; import java.util.Scanner; public class LetterMailing { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); int numSheets;
I've looked at multiple sources and everyone is saying different stuff. Which one should I be using? FileWriter/FileReader, other people was saying PrintWriter, and one even said : "Formatter" which is the one I'm doubting mostly. My purposes for writing files is for like saving maps, saving high scores, etc.
I'm working on assignment for a class where I'm creating a home utility auditor. Basically the user has to pick from a list of appliances and then input various fields to calculate a total cost. When the user chooses "washer" from the list of appliances, they must enter in values for 2 separate fields, and will then click calculate to get total cost. I've been trying to implement this through an if, else statement, but it's not wanting to calculate a total cost and I'm running into errors. I've put the code below.
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // The calculate button will multiply the 3 fields that the user inputs: //cost*Kw used*hours used=total cost of operation float num1,num2, num3, result; //now, parse the text to a type float num1= Float.parseFloat (costField.getText ());
I have accountsData.txt file in my default package, this is the file it should be writing to and reading from.
There is an ATM class, which has the main in it. From here the program is supposed to work like an atm, you type in your account number and can withdraw or deposit. It is supposed to then write the changes to the file.
//Read from a file. public void loadAccounts(String inputFileName) throws IOException { Scanner fin = new Scanner(new File(inputFileName)); // Variables to store the values.[/color] int account = 0; double balance = 0.0;
Okay so I have to write a method to compute the following series: m(i)= 1/3 + 2/5 +....+ (i / 2i+1) and write a test program that displays a table " i = m(i)" 1=0.3333 2=0.7333....all the way down to 20 which is 9.2480. I have written something and cannot seem to get the sum of the fractions to display .
public class ExtraCredit1 { public static void main(String[] args) { double num; double sum = 1;
public class Tester { public static void main(String[] args) { Product p1 = new Product(); p1.loadFromFile("Monitor.pr"); System.out.println("Actual: " + p1.toString()); System.out.println("Expected: Product [id=12345, name=Monitor, description=A freakin great monitor!]");
p1.setId(11111); p1.setName("another product"); p1.setDescription("Description of another product!");
[code]....
The expected output is what my program should be doing and the actual output is what it's doing instead. As you can see, my code works for the middle test. But I cannot understand why it won't load the first fileFor the second half, the id and the quantity are separated by a comma... I'm not really sure how to deal with that. As you can see, I tried using a delimiter, but it doesn't seem to be doing any good.
Recently I discovered power of Java, I'm coming from Perl, Python world so I'm at very beginning. I have firm understanding of OOP and I'm ready for new challenges. I have question regarding writing to database performance and theory.
Basically as my personal project I'm trying to write some small program or addon which will enable me to write concurrently to database. Let's say that I have some software and that has FIFO output to database in single stream, but since the output interface is not fast enough congestion can occur if the input to the system is high.
I would like to extend that software with addon which will take that one output stream and create 2,3,4 concurrent input streams towards database. API from that software is provided so I can redirect output to third-party extensions and apps.
I realized I wasn't capitalizing certain things, and when I did it i was able to run the compiler. is there a utility or tool that auto formats the capitalization and such? I read kathy mentioning about eclipse I installed I don't know where that feature is.
I need to write a program that, when a button is pressed, will add the user input to a table AND write it to a sequential data file. I have everything done accept for how to write the data sequentially(all input data on the same line in the file). The following is part of the code:
private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) { DefaultTableModel dtm = (DefaultTableModel)jTable1.getModel(); dtm.addRow(new Object[]{donorName.getText(),charityName.getText(),donationAmmount.getText()}); //Adds user input to the table try { FileWriter writer = new FileWriter("FundraisingInformation.txt",true);//Creates file or adds to it BufferedWriter bw = new BufferedWriter(writer);
[code].....
I would need the file output to be in the following format:
donorName charityName donationAmmount
As I said, using the .write(bw) i know how to make it look like:
I have a java code that should sort an array of names based on the last name. e.g jane a, jane b, jane z, jane d should be jane a, jane b, jane d, jane z. I have the following code but for some reasons, the s1 in the comparator method is always null.
public class ShuffleName { public static void sortNames(String[] names){ Arrays.sort( names, new Comparator<String>() { public int compare( String s1, String s2 ) { String s1last = s1.split("s+")[1]; String s2last = s2.split("s+")[1]; return s1last.compareTo(s2last);