Math Integration Across Multiple Arrays
Feb 14, 2014
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];
[code]...
View Replies
ADVERTISEMENT
Nov 23, 2014
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.
View Replies
View Related
Dec 25, 2014
I am attempting to grab stock prices for an array of different stock tickers. In my code, I iterate through the array of stock tickers and at the same time, grab the stock prices from an API. Then, I store the stock prices into a new array and attempt to display the new array.
For example: An array element may contain 'AAPL' as a stock ticker. The for loop enters this element into the URL which links to an API, grabs the stock prices, stores it into a temporary variable. Then it stores the value (the stock price) of that temporary variable in to a new array. Then the new array will attempt to print out this stock price along with all the other stock prices.
Here is my code:
public static void getStock(String[] tickers) {
for (i = 0; i < tickers.length; i++) {
try {
URL url = new URL("http://query.yahooapis.com/v1/public
[Code] .....
The above code works fine if I am printing the stock prices from inside the for loop. And I can see why, it enters and prints the new stock price in the new array through each loop.
My problem is, I do not know how to access the new array (stockOutput) outside of the for loop, or how to display its contents outside of the for loop.
View Replies
View Related
Mar 20, 2015
I am creating a roulette program that I converted from C++ to Java. Why its not finding the main class. Therefore it will not compile. Heres the code:
import java.util.Scanner;
public class P1RouletteDB
{
// This program demonstrates the use use multiple arrays to play a roulette game.
//Also a random number will generated to be used as the ball in the game. The user will be provided the random number to test the win algorithms
// Program Set 2 Roulette Game
// Global constants
public static final int COLS = 3; // Number of columns in each array
[Code] ....
View Replies
View Related
Nov 18, 2014
In my integration test, I tried to use resttemplate to send a Get request to a dummy server created by MockMvcBuilders. However I got an error:I/O error on GET request for `"http://localhost:8080/test"`:Connection refused:(In the function testAccess(), url is `"http://localhost:8080/test"`). My code is as below:
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@IntegrationTest("server.port=8080")
public class MyTest {
private MockMvc mockMvc = null;
[code]....
View Replies
View Related
Mar 10, 2014
I am familiar with Servlet/jsp's and developed a web application using them. Now I am looking in Websocket of Java 7. Documentation is not clear how to integrate the two.
1. Let us say in my listener, I have already determined database connections, log file for log4j etc.. Can I use it in Websocket Java classes based on annotation API of web socket. What is not clear to me how I will access Context parameters for webapp saved in Listener.
2. I like jsp so I can dynamically modify the html to be shown. If I am using api, how will I do that, I know I can return data from websocket, but all the java logic which jsp provides, how can that be implemented using web socket api.
Show trimmed content
View Replies
View Related
Jan 21, 2015
While usiing JSF f:ajax tag, I am getting the following error for not being able to load jsf.js file.
Looking for resolving this error?
JSF1064: Unable to find or serve resource, jsf.js.xhtml
View Replies
View Related
Aug 7, 2014
I am trying to integrate the finger-print scanner to struts application. I only have it's executable jar file through which the device will operate and the required signature can be taken . I am not getting how to integrate this in my application or in the required jsp page.
View Replies
View Related
Jun 28, 2014
I mainly would like to know is a int[4][4] or a int [4*4] is more efficient to use. Which takes more storage? Which requires more to process? that kind of stuff.
View Replies
View Related
Sep 14, 2014
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;
[Code] ....
View Replies
View Related
Feb 27, 2015
I have a math expression in a String, that I want to split into 4 pieces as in the following example:
String math = "23+4=27"
int num1 = (23 STORES HERE)
int num2 = (4 STORES HERE)
String operator = (+ STORES HERE)
int answer = (27 STORES HERE)
Note that the operator can be either + - * /
View Replies
View Related
Sep 18, 2014
Here is the assignment:
Prompt the user to input two sides (a and b) of a right triangle. Calculate, using the
formulas below, the hypotenuse and the other two angles of the triangle. Calculate the
perimeter and the area.
Here are the formulas:
a^2 + b^2 = h^2
sinθ = a/h
A + B + C = 180 degrees
how to start this program out, i know which math classes i need to use.
View Replies
View Related
Sep 14, 2014
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];
[Code] ...
View Replies
View Related
Feb 22, 2014
package statics;
public class Test_main {
public static void main(String[] args) {
Math.log(50.00);
}
}
I am able to use a Math method without importing the java.lang.Math. Which makes me think
1) What is the use of the import statement in java?
2) Is my IDE taking care of the import automatically?
I am using Eclipse IDE and JDK 1.7.
View Replies
View Related
Oct 14, 2014
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:
futureInvestmentAmount = investmentAmount * (1 + monthlyInterestRate)^(numberOfYears*12)
Here is my code:
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.
View Replies
View Related
Jan 20, 2015
I'm trying to convert a Formula to run in a java program.
This is the formula:
(you can ignore the modifier part)
This is my attempt. However it prints out 0.0
import java.util.Scanner;
public class DamageCalc{
public static void main(String[] args){
Scanner s = new Scanner(System.in);
[Code].....
View Replies
View Related
Sep 1, 2014
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) ???
View Replies
View Related
Feb 17, 2015
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();
[Code] ....
View Replies
View Related
Feb 4, 2015
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.
View Replies
View Related
Nov 2, 2014
I am doing this math for my assignment where you have to find the imaginary number.
double dem = (b*b-4*a*c)*-1;
double dem2 = Math.sqrt(dem);
realPart = (-b/(2*a));
imagine = (dem2)/(2*a);
imagineneg = (dem2)/(2*a);
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.
View Replies
View Related
Nov 15, 2014
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).
View Replies
View Related
May 18, 2014
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();
[code].....
View Replies
View Related
Feb 25, 2015
Java program : For this assignment you are going to write code for the following class:
MathOnThreeNumbers
Here are the specifications of class MathOnThreeNumbers:
Methods of class MathOnThreeNumbers:
1. inputThreeNumbers
2. getAverage
3. getSum
4. getNumberOne
5. getNumberTwo
6. getNumberThree
Constructor of class MathOnThreeNumbers
write a constructor that initializes the first, second, and three numbers to 1, 2, and 3 respectively.
Specs for the methods methods:
1.
name: inputThreeNumbers
accessibilty: public
arguments: none
what it does: asks the user for three numbers of type double
2.
name: getAverage
accessibilty: public
arguments: none
what it does: returns average of the three numbers
3.
name: getSum
accessibilty: public
arguments: none
what it does: returns sum of the three numbers
4.
name: getNumberOne
accessibilty: public
arguments: none
what it does: returns the first number entered by the user
5.
name: getNumberTwo
accessibilty: public
arguments: none
what it does: returns the second number entered by the user
6.
name: getNumberThree
accessibilty: public
arguments: none
what it does: returns the third number entered by the user
Here is an example of how the class MathOnThreeNumbers works. The following code produces the output displayed after the code.
MathOnThreeNumbers mm = new MathOnThreeNumbers();
System.out.println("first: " + mm.getNumberOne());
System.out.println("second: " + mm.getNumberTwo());
System.out.println("third: " + mm.getNumberThree());
mm.inputThreeNumbers();
[Code] .....
View Replies
View Related
Apr 26, 2014
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
View Replies
View Related
Jul 24, 2014
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?
View Replies
View Related
Jan 27, 2014
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);
Vector3f v1 = new Vector3f(B.x - A.x, B.y - A.y, B.z - A.z);
Vector3f v2 = new Vector3f(C.x - A.x, C.y - A.y, C.z - A.z);
float[] i = new float[]{v1.x, v2.x};
float[] j = new float[]{v1.y, v2.y};
float[] k = new float[]{v1.z, v2.z};
[Code] ....
View Replies
View Related