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 have to read a text looking for value related to certain variable. The variable are always DE plus identifier from 1 to 99 or DE plus identifier from 1 to 99 and SF plus identifier from 1 to 99. The value can be alphanumeric. How can I get these values? As a start point, I try to use split("DE") but I can get something that is wrong if there is "DE" inside the text that doesn't me interest. I look for scanner but it doesn't work. I guess that there is some way, maybe using regex but I am completely lost ( I have never used regedix before and I am in rush to fix this).
Basically, the text is similar to the below where DE means data element and sf sub field. Some data elements have sub fields while others don't. I guess that there is a way to split with something like DE+anyNumberFrom1To99 = theValueAimed in some array and DE+anyNumberFrom1To99+,+SF+anyNumberFrom1To99 = theValueAimed in other array.
DE 2, SF 1 = 00 SOME TEXT THAT DOESN'T INTEREST ME DE 22, SF 1 = 0 SOME TEXT THAT DOESN'T INTEREST ME DE 22, SF 4 = 1 SOME TEXT THAT DOESN'T INTEREST ME DE 22, SF 5 = 0 SOME TEXT THAT DOESN'T INTEREST ME DE 22, SF 6 = 11 SOME TEXT THAT DOESN'T INTEREST ME DE 22, SF 7 = 90x SOME TEXT THAT DOESN'T INTEREST ME DE 22, SF 7 = 12ab SOME TEXT THAT DOESN'T INTEREST ME DE 99 = 1234 SOME TEXT THAT DOESN'T INTEREST ME
Regular expression which I want to use to split a string. The string could look similar to this:
"a = "Hello World" b = "Some other String" c = "test""
The String is read from a file where the file contents would be:
a = "Hello World" b = "Some other String" c = "test"
After splitting I would like to get the following array:
String[] splitString = new String[] {"a", "=", ""Hello World"", "b", "=", ""Some other String"", "c", "=", ""test""}
I know I could just write a simple text parser to go over the string character by character, but I would rather not do it to keep my code clean and simple. No need to reinvent the wheel.
However, I just cant seem to be able to find the right regular expression for this task. I know that a RE must exist because this can be solved by a finite automaton.
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;
Given a string of numbers and operator. Compute as follows:
Consider, "000293000002030403+0400293059694" is the input.
a. Separate the two operands and one operator: "000293000002030403" "+" "0400293059694"
b. On each string operand, take each digit. ADD them all. (2+9+3+2+3+4+3) + (4+2+9+3+5+9+6+9+4) The two string operands should now become two integers.
c. Lastly, perform the operation using the string operator specified on the original string. 26 + 51 = 77
I don't know why I get the sum of 52 when I use a for loop.
Here are my codes:
public class string2math { public static void main(String[] args) { String input = "000293000002030403+0400293059694"; String [] operand = input.split("+"); String firstOpera = operand[0];
I'm having extreme troubles with my outputs not displaying the correct math. I have everything organized how I want it, it's just not giving me the correct answers.
The code is supposed prompt the user to enter an investment amount and an interest rate and display the future investment amount for years 1-30. The formula for this is:
import java.util.Scanner; public class InvestmentValue { public static void main(String[] args) { // prompt user to enter data Scanner scan = new Scanner(System.in); System.out.println("The amount invested: ");
[Code] ....
And I have to use a method to do this as it is what we are learning in class right now. A sample output as of now is:
The amount invested: 1000 Annual interest rate: 9 Years Future Value 11.0E15 21.0E27
[Code] .....
And obviously a future investment amount cannot equal infinity.
I am trying to complete an assignment and I am stuck on a key point. I must print the total inventory value across each of these arrays, as it prints for each "list". To do this, I understand that I need some form of correlation between my variables "total" and "Price" between each array. My quandary lies in the way that I have designed this code to begin with. I am not sure where to add the math section of code that is needed, nor am I fluent enough with Java to know how to call all of the arrays as it prints. Listed below is my code, when you compile it the total inventory value is 0 for each "list".
package inventory; public class Inventory { public static void main (String[] args) { List[]list = new List[5];
building a game. the game is all about the multiple times table with levels. easy medium and difficulty. I dont even know where to begin and what is the codes to use or even the platform. what websites can be access etc and what is the big deal with code tags.
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) ???
This program is supposed to ask for the operator (+ or -) then ask you for two numbers and do the math. When I run it it comes up- Enter operator. When I say add or sub nothing happens. Here it is:
import java.util.Scanner; public class Echo1{ public static void main(String args[]){ Scanner userInput = new Scanner(System.in); System.out.println("Enter Operator"); String operator = userInput.next();
I am a 3rd year electrical engineer and I am working on a project on solar cell design in the developing world.For my project I am looking to create a very simple web page which can be used by people in the developing world to determine whether a photo voltaic system is suitable to their needs.
For this I want to have simple boxes where a user can input numbers and I used complex calculations to return values (a lot of trigonometric functions etc.), the values then should have the opportunity to be altered to the users digression. This will create a solar model.
For the load aspect of it I am looking to have drop down boxes for a number of components which the user can select and will have a numerical value in Watts which will sum to give total load on system. Ideally I would like to show this graphically in a pie chart showing how much energy each component is taking to give the option to remove.
I am also creating a statistical model which determines the likelihood of having no sunlight on a given day which looks at the solar output, battery capacity and load on the system and will return reliability of the system - this has not been completed but should be shortly.
Aim is to keep web page as simple as possible as unskilled computer users may want to use it.
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.
I am trying to make a calculator that ranges from simple math to trig. I am trying to start the j-frame for it and I already have most of the formulas programmed with the if-else statements and such. How do I go about starting the jFrame and marrying the 2 codes together to start it. (I have taken a bit of programming but relatively new to writing j-frames and using other classes and putting them together).
So my little math game is working so far. I can only do addition though. I know how to fix it if I can find out how to generate random math operators. After that I want to use a loop (or a better technique) to ask ten different math questions before the game is over.
package pkgnew; import java.util.Scanner; import java.util.Random; public class New { public static void main(String args[]) { //Declare and construct variables Random randomnum = new Random();
I want make a math equation game. usually math game use equation for the question and we answer that equation. ex : what is the result of 2*5 / 2+2/ 2^2 etc. and we answering that. but i want to make it different so i want to make the equation answer as the question and the equation as the answer of the game. Ex : the question is 54 so we can answer it with 9*6 or 24+30. and this is my java code
package coba; import java.util.Scanner; public class Coba {
public static void main(String[] args) { double angka = Math.random()*70;
[Code] ....
but when i run it the error code show like this : Quote
I am running into some trouble with Line-Plane intersection, my method works, provided I am perpendicular to the plane I want to intersect. This is caused be the plane equation (with my given x, y, and z coordinates, the equation is -Z - 1 = 0). So the equation is only relying on the Z value of anything inputted. Is there another way to calculate the equation of a plane that would rely on all axis? Here is my current code:
Java Code:
Vector3f A = new Vector3f(0, 0, -1); Vector3f B = new Vector3f(0, 1, -1); Vector3f C = new Vector3f(1, 1, -1);
How do you use power of math. I'm trying to write a calculator to calculate the volume of a cylinder by asking the user to enter the height and radius but when I use pow(2) it doesn't work. I imported java.lang.math class so i dont have to keep using math. for now my code runs just fine since I'm using radius * radius but I would really luv to use the power instead times each other when i have to use higher powers.
import java.util.Scanner; import static java.lang.Math.*; public class Lab2 { public static void main(String[] args) { Scanner scan = new Scanner(System.in);