i am trying to calculate the number of months it takes to pay off a set amount of credit card debt given the following information: principle amount, annual interest rate, and monthly payment. How to import the formula necessary to system.out.print the answer (number of months it takes to pay off debt) ???
Let's say hypothetically you're making a huge program and use a lot of imports (ex import java.util). If you only need a few specific things from java.util, will it use more memory importing java.util.* compared to only importing lets say java.util.Scanner, java.util.ArrayList, etc. Basically does importing a whole package use more (if any at all) memory than only importing specific package parts?
So basically I am trying to get it that the number inside the square root isnt negative. So lets say I enter a: 1, b: -1, c: 4.25. When you do the discriminant it would be -16 but I want that to be positive so I multiple it by -1 (thats the dem part). Then I sqaure root the whatever the answer is and then go to the imagine and imagineneg part where you find the imaginary number.
My problem is that instead of it being -16*-1 to get 16, some how I get 15.
The area of a square is stored in a double variable named area . Write an expression whose value is length of the diagonal of the square. Do I use math.sqrt?
I am working on this new project where we are using the great distance formula but every time I run my ending result is NaN. I was researching, and people say its because you divide by 0. I think I have my formula correct.
Java Code:
public class testingFormula { public static void main(String[] args) { double lat = 34.01858902; double lon = -118.2817688; double lat2 =33.94530869; double lon2 = -118.3994904;
It's suppose to generate a table with the month, and the new amount of the CD. Right now, the program generates a continuous table for months, but it doesn't update the value of the CD.
import java.util.*; public class Excercise04_31 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in);
I have just started to learn programming in the book I am teaching myself from it said how would you write the following arithmetic expression with it being the quadratic formula but only the plus part of it in the plus or minus..
package javalearning; import java.util.Scanner; public class QuadraticFormula { public static void main(String[] args){ Scanner input = new Scanner(System.in); System.out.print("Enter value for B: "); double B = input.nextDouble(); System.out.print("Enter value for A: "); double A = input.nextDouble(); System.out.print("Enter value for C: "); double C = input.nextDouble(); double negativeOfB = -B;
Still trying to get a handle on arrays! So, I declare an array to be a 46x1 and I am trying to populate it with a Log formula that I am using but I keep getting an ArrayIndexOutofBoundsException.
Code :
private double[][] LNValues = new double[46][1]; //Calculating y=LN(E-k) and Initializing the Array for(int x=0; x<LNValues.length; x++) { double i = Math.log(eValues[x][1] - kValue); if(i > 0)
I'm supposed to take an input from the user and calculate the value of pi using this formula: 1/1 - 1/3 + 1/5 - 1/7 etc... so on alternating between minus and plus and denominator increasing by 2 every time. If the user inputs the number 3, then it should print (1/1 - 1/3 + 1/5 - 1/7 + 1/9) *4. The idea here is that the higher the input of the user is, the higher the equation will be close to pi.
This is what i have so far :
import java.util.Scanner; public class Pi { public static void main(String[] args) { double first = 1/1; double second = 1/3; Scanner input = new Scanner(System.in); System.out.println("Enter a Number to calculate how far you want the formula to perform: "); double count = input.nextDouble(); } }
This is literally all i have, i know i need a while loop and an if loop.
Write a program named QuadraticTable.java that takes three double arguments and two int arguments (in that order) from the command line. The three doubles will represent a, b, and c from the quadratic formula.
If the discriminant is non-negative, find and print the solutions to the quadratic equation. (The plus/minus sign in the quadratic formula indicates that you would separately perform both operations). Otherwise print "no real solutions".
Then using the last two int arguments as x_min and x_max, print a table of x and ax
2 + bx + c
values using the a, b, and c read in as command line arguments.
Sample output: (command line arguments were 1 0 2 -3 3)
I have this formula for creating quarter wave antennas, however for some reason I can not get the right answer for it. double parM takes the users information which is a frequency in Megahertz and changes to feet so we can construct our antenna. However, in the program it gives me 1.9 instead 7.7 which it is suppose to be.
double parM = Double.parseDouble(userInput.getText()); double getSize = (234 / parM) * 12; // 12 is in inches
So Ive got to make a turtle on an image draw a semicircle that starts at the top of a circle and goes down and to the left, changing colors halfway through. I've got everything down, I can draw the turtles and make them do straight lines. My problem is more math related. I need to use the equation of a circle, give it points, and figure out how to write that code in java.
We use the equation for a circle: (x - a)^2 + (y - b)^2 = r^2
I want to import an image to resize but not sure how to start of.Should I be using the "BufferedImage & ImageIO.read" method or the "paint(Graphics g) { Image img1 = Toolkit.getDefaultToolkit().getImage" method?
"Import org.apache.commons.codec cannot be resolved", which after searching seems to be a somewhat common problem. The solution being to go to: FileUpload - Home and download some jar file and add it to the /web-inf/lib folder. yet the error persists even after adding the jar file in "add external jar files" and restarting eclipse.
The jar file I added is called "commons-fileupload-1.3.1.jar" which is the only one I could find in the zip file. I've searched around looking at numerous threads about the issue, several of them sadly several years old, with no success.Surely installing a library to eclipse shouldn't be this complicated?
I have been working on project (developing web interface for generating dynamic reports)for that i have downloaded dynamic reports library and i want this library to be imported for my project to jsp page on netbeans 7.2 how can i do it?
Basically its a program where a user is prompted to enter the length of all three sides of a triangle and the program calculates the area by herons formula and can tell if the triangle is equilateral or Pythagorean. I am having trouble entering a formula to where all three enter sides cant possibly be a triangle. Here is my Program. Where the '?' is stated.
import java.util.Scanner; public class Triangle { public static void main(String[] args){ double a; double b; double c; double s; double x; double area;
When importing static members of a class. Why are they only accessible within the constructor of the calling class, and not outside of it? Here's the source code to understand my question.
package Certification; public class ExamQuestion { static public int marks ; static public void print(){ System.out.println(100);
Ok so I know how to import a csv using java. What I'm curious about doing is importing a csv using file chooser, reading the data, sorting the data out by certain parameters, and then outputting a count of each parameter I chose. Say for example I have columns 1,2 and 3. Column 1 has the name, column 2 has the percentage, column 3 has an o'clock time. I want to use queries to sort through the parameters and have a count of each parameter I choose...
I'm currently using TextPad or command prompt to compile and run my programs, and as usual I am not having any luck importing external libraries, in particular apache commons.
I couldn't see any particularly obvious settings in TextPad to set a library or class path (which is annoying as I really like the program), so I jumped back to cmd prompt to run it from there. Aaaaaand i don't understand .
This is my file structure at present:
/mainProject //includes .java and .class files, and where I've successfully placed .jar files before.
The apache commons zip file was extracted here, making:
/mainProject/commons-lang3/apidocs/orgs/apache/commons/<folders> //the commons-lang3 folder contains the jars I'm navigating to the /mainProject folder in cmd prompt and typing (amongst many other things) javac -cp /mainProject/commons-lang3 MonsterGame.java //with the -cp being pointed at the folder the .jar is in i've tried pointing it at the root folder where the import statement begins in the code (ie mainProject/commons-lang3/apidocs), tried moving the .jar files to the mainProject folder (pointing -cp at it) and more. No luck.
it seems everytime i try to import a new library something goes wrong..... its become a bit of a stumbling block to be honest. I seem to spend most of my time dealing with the 'administrative' side of coding (that was the politest way i could put it ), am I not doing it right?
I've read I'm supposed to include the .jar in the classpath, not just the directory. is this correct? (it still doesn't work...!)
I've been trying to write a program for some time now, but im encountering problems while trying to complete it. The program has a student class and a course class (set up with some info about the class, like #, professor name, course title, course time). Now, i have a text file in the workspace, and i have to import the data from the textfile, and thats just what i did, but then there is an option which allows the user to delete a course only by inputing the course number, and when he does that, the program outputs the course's name, and confirms the deletion of the course (From the student's record, i created a vector for that and imported all the courses from the text file). But how can i let the program know what's the name of the course when the user inputs the course number ???
When the data is read from the file, objects should be created and added to the student's course record. <- i think here's where i messed up ? i imported the data, but how can i actually make them objects before adding them into the vector ?
PHP Code:
public static void main(String[] args) throws IOException { Scanner scan = new Scanner(System.in); Vector Record = new Vector(); try {FileReader filereader = new FileReader("CLASSES.txt"); BufferedReader bufferedreader = new BufferedReader(filereader); String test = ""; while(test != null) { Record.addElement(test); test = bufferedreader.readLine(); } mh_sh_highlight_all('php');
1. Tried to use setLayout() but it wouldn't let me. Have imported libs
import javax.swing.*; import java.awt.*;
but it doesn't work. It only worked when I extended a class with JFrame. Why do I have to do it? I already have a JFrame instance:
public test(){ JFrame frame = new JFrame(); frame.setTitle("Workshop"); frame.setBounds(500,300,400,300); frame.setVisible(true); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); .... }
This code runs smooth, so it's confusing for me that it lets me create a JFrame object, and put buttons onto it, but it wants me to extend the class onto JFrame class in order to use a method.
2. I've read somewhere that AWT is old and should not be used anymore. Is there a diagram or a list with objects and properties that are manipulated only by Swing so that I could concentrate only on those? For example (made up list):