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) ???
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'm converting from ASP to Java for a legacy site. I believe the first part of the if statement is right but I'm having an issue within the else staetment. I'm getting date is undefined, I've tried using getYear and getDate but have not been successful.
ASP:
If Request("action") = "results" Then aMonth = Request("selMonth") aDate = cint(Request("selDate")) aYear = cint(Request("selYear")) Else aMonth = UCase(MonthName(Month(Date()),true)) aDate = Day(DateAdd("d",-1,date())) aYear = Year(Date()) End If
I compiled a java program and converted it to an exe file and it works fine on the computer I created the java file in but when i try it on another computer it gives me a "Java Virtual Machine Launcher - A Java Exception has occured" error message.
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.
I am trying to use a for loop for getting hours for an employee for five days. how to convert my pesodocode into java language so that it will compile. This is what my pesodocode looks like:
begin getHours() for(index=0; index <5; index++) get hours **System.out.println() **inputString = input.readLine() **plumbersHours[index] = plumbersHours [index] = integer.parseint(inputString) endfor index = 0 while (index < 5) totalHours + = plumbersHours[index] index++ end while return
I am trying to Extract the ranges of Variables from a Text File. I extracted lines of the forms X in 1..10 Y in 12..50 Z in 0..19 / 66/ 95..100 Where X in 1 ..10 states that X takes values from set 1 to 10 Similarly for Y and for Z its a Union of different ranges of the values (0 to 19, union 66,union 95 to 100)
I want to Map these Variables to their respective sets using Hashmap where Key is Variable name and value will be a Set. My Hashmap Signature is HashMap> hm=new HashMap>();
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
how to use Java and for my coursework I have been asked to construct an application that will read in the exam mark and coursework mark and then print out to 1 decimal place the average of the coursework and exam mark. When I submit it to the coursework submission system it says it's incorrect.
The answer that it's asking for is the answer that my code produces (ex = 71 cw = 40 mark = 55.5) But for some reason it says this when I submit it:
-#### << Differences between expected (<) your answer (>) >> ------------ 1c1 < ex= 91 cw = 80 mark = 85.5 --- > ex = 71 cw = 40 mark = 55.5 -------------------------------------------------------------------------
Check the above output for why this attempt failed And when I change the ex to 91 and cw to 80 it asks for > ex = 71 cw = 40 mark = 55.5 again.
class Main { public static void main( String args[] ) { int ExamMark=71; int CourseworkMark=40; double cost = (double)(ExamMark + CourseworkMark) / 2; System.out.printf("ex = " + ExamMark + " cw = " + CourseworkMark + " mark = " + cost); System.out.println(); } }
I am trying to create a program that allows me to enter 5 students numeric grade (0-100) to a letter grade (A, B, C, D, F) and I CANNOT use an array. When I try to run my program it says main class not found, and when I change the it from a string to a void in the main method it does not work.
Java Code:
import java.util.Scanner; public class Week3ControlStatements2 { public static String main(String[] args){ int numberGrade = 0; int quotient = numberGrade / 10; int remainder = numberGrade % 10;
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 am trying to write a program for converting positive binary inputs into hex. in the hex output the point (".")is missing.
Suppose my expected output is e7.6 , but i am getting e76
only the "." is missing.
here is my BinToHex class..
import java.io.*; public class BinToHex { double tempDec,fractionpart; long longofintpart,templongDec; String input ="11100111.011"; String hexOutput=null,tempDecString,hex = null; static int i = 1;
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;
I'm trying to calculate sin(x) without using Math.sin(x). The formula for sin(x) is: x - x^3/3! + x^5/5! ... I can't seem to get the coding for the alternating +/- right. Here's my program:
import java.util.Scanner; import java.lang.Math; class Sin { public static void main(String[] args) { Scanner kb = new Scanner(System.in); int n, c, fact = 1, count = 1; double x, sum = 0, sum_sin = 0, result;