Create A Program To Calculate Roots For 2 Degree Equation

Oct 14, 2014

I just created a program to calculate the roots for a 2. degree equation, When I first created my program, I defined the r1 and r2 as double, but got an error saying they needed to be defined as String, why is that?When should I be using string? I am new to java and I have mostly only used int, double and Boolean so far.

import java.util.Scanner;
import java.text.DecimalFormat;
public class c3e1 {
public static void main(String[]args){

[code]....

View Replies


ADVERTISEMENT

Vector Math - Calculate Equation Of A Plane That Would Rely On All Axis

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

Create A Program That Will Calculate Different Tax Brackets

Oct 3, 2014

I have spent the past 12 hours on it and have gotten no where. I need to create a program that will calculate different tax brackets. I have tried all combinations I can think of and can't get it to work!!! I am literally about to go insane! I need the program to calculate tax will be 1% for anything up to $50000. If the tax is over $50000, you keep that 1% of $50000 and then add the remaining. So for an income in the second range, it would be 1% of $50000, and then 2% of (income - $50000). This then continues for each range.

The problem I'm having is getting it to display the correct interest rates. I am not asking for you to write it for me. I want to learn. But at this point I have exhausted all resources available to me.

import java.util.Scanner;
public class Project3taxinfo {
public static void main(String[] args) {
final double RATE1 = 0.01; //1% tax on the first $50,000
final double RATE2 = 0.02; //2% tax on the amount over $50,000 up to $75,000
final double RATE3 = 0.03; //3% tax on the amount over $75,000 up to $100,000
final double RATE4 = 0.04; //4% tax on the amount over $100,000 up to $250,000
final double RATE5 = 0.05; //5% tax on the amount over $250,000 up to $500,000
final double RATE6 = 0.06; //6% tax on the amount over $500,000

[code]....

View Replies View Related

Create A Program That Calculate Price Of Carpeting For Rectangle Rooms

Apr 23, 2014

I am not getting any syntax errors but the program simply does nothing when I run it.

I literally just get "run: BUILD SUCCESSFUL (total time: 3 seconds)".

So basically, I need to create a program that calculates the price of carpeting for rectangle rooms.(multiply the area of the floor by the price per square foot of the carpet).

-The RoomDimension class should have two fields: one for length and one for width, and a method that returns the area of the room
-The RoomCarpet class that has a RoomDimension object as a field, a field for the cost of carpet per square foot, and a method that returns the total cost of the carpet

Here is what I have:

package roomdimension.java;
public class RoomDimension {

private double length=0;
private double width=0;
private final double area = length * width;

public void RoomDimension(double len, double w)

[Code] ....

View Replies View Related

Solver For System Of Linear Equation In Java For Large Matrices (finite Element Program)

Jan 16, 2014

I develop a finite element code at java. I am looking for efficiency solver and fast for large, sparse , symmetric and positive define matrices .

i used in jblas but i encounter in problem when the matrix has high condition number(ill condition number) and i get error for singular matrix while in mathematica i succeed to solve that system without problems...

Any good solver and fast solver package in java can i use for solving that system?

View Replies View Related

In And Out Degree Of A Graph

May 2, 2014

I have this code for reading a text file and printing out information about the graph, the program works perfectly but I need to figure out the in degree and out degree of the graph if it is an directed graph. So my question is how would I go about implementing that? I know what in degree and out degree does but in terms of the code I'm not so sure, so I'm thinking if the case of vertex 0,1 the first vertex comes before the second vertex so that would in an in degree right? But how would I do that?

graphs.txt
6,1
0,2 0,4 1,4 1,5 2,1 2,3 2,5 3,2 3,4 4,1 4,5 5,1 5,3 5,2

import java.io.File;
import java.util.Scanner;
 public class Vertices {
public static void main(String[] args) throws Exception {
@SuppressWarnings("resource")

[Code] ....

View Replies View Related

Evaluate Nth Degree Polynomial For A Given Value Of X

Apr 8, 2014

To evaluate a nth degree polynomial for a given value of x using JAVA PRG.

E.g. 5x^7 + -2x^5 + 6x^3 + 1x^0 at x=2

The program must read in the number of non-zero terms in the polynomial followed by the co-efficient and power of each term. The value of x is read from the used and the program display the results of the evaluation of the polynomial. Use array list to represent the polynomial.

Test Case 1:
Input: No of terms: 4
Term n-1 to 0 (both coeffient and power )
5 7
-2 5
6 3
1 0
x = 2 (say)

Output :
625

View Replies View Related

Getting NaN For Roots (Quadratic Solver)

Nov 18, 2014

This was the way I was supposed to write it (every thing separated). Any way, I was wondering why when ever I try to run I only get NaN for roots, and my discriminant is off

/**
* Find roots of quadratic equations
*/
import java.util.Scanner;
public class QuadraticProject {
public static void main(String[] args) {

[Code] ....

View Replies View Related

Roots Of Nonlinear System Of Equations

Oct 10, 2014

I am in search of a library that has been created in JAVA that can be utilized to solve for roots of a nonlinear system of equations. Each equation has 2 variables, x and y, and will need a library that uses higher calculus equations. No ones that just solve for x.

Most of the libraries that have been created to solve nonlinear equations are either in Fortran, C, or Python. There are a few libraries such minpack/scipy. The only libraries that I have been able to find or programming solutions that are in JAVA either require additional programs such as Matlab or are commercial products

I did find one library put together by a professor in Colorado State, but am unsure how to use it. There does not seem to be a way to enter your functions in the code.

Newton Raphson Method - Multivariable(x and y)

[URL] .....

How to use this library or find a library that can be used in an android application would be amazing.

View Replies View Related

Angling Reflectors 45 Degree - Making It Change Angle With Click

Nov 24, 2014

// scene object variable
var renderer, scene, camera, pointLight, spotLight;

// field variables
var fieldWidth = 400, fieldHeight = 200;

// paddle variables
var paddleWidth, paddleHeight, paddleDepth, paddleQuality;
var paddle1DirY = 0, paddle2DirY = 0, paddleSpeed = 3;

[Code] .....

View Replies View Related

Solving Roots Of Nonlinear System Of Equations

Oct 10, 2014

I am in search of a library that has been created in JAVA that can be utilized to solve for roots of a nonlinear system of equations. Each equation has 2 variables, x and y, and will need a library that uses higher calculus equations. No ones that just solve for x.

Most of the libraries that have been created to solve nonlinear equations are either in Fortran, C, or Python. There are a few libraries such minpack/scipy. The only libraries that I have been able to find or programming solutions that are in JAVA either require additional programs such as Matlab or are commercial products

I did find one library, but am unsure how to use it. There does not seem to be a way to enter your functions in the code.

Newton Raphson Method - Multivariable(x and y)
www(.)math.colostate(.edu)/~benoi...s/solvers.html

How to use this library or find a library that can be used in an android application.

View Replies View Related

Create Array / Store 5 Objects And Calculate Total Price - VAT Rate

May 6, 2014

How can I do the work below in Java

In this main class, create 5 objects of the class Menu, as defined in the table below.

Name amount of calories cooking time price per person number of drinks

Fufu and Groundnut Soup 564.65 2515.572
Red Red 345 12 9.980
Rice and Beef Stew 560.4 1512.651
Ga Kenkey and Fish 780 10 10.15 1
Banku and Tilapia 450.4 35 25.17 2

Exercise d
In your main class create an array of length 5, and store the 5 objects (Exercise c) into the array. You can use any name for your array.

From the array, use a loop to: Print the details of all the objects using the method you defined in Exercise b.

Exercise e
Use another loop to:
-Print only the name and cooking time of all the dishes that take less than 30 minutes to cook. Hint: you may use the getter methods for the name and cooking time attributes, and then, print these values (name, cooking time).

Exercise f
Use another loop to :
-Calculate and print the total price of all the objects (in the array).
-Calculate the total price of all the objects with VAT included for each dish (VAT rate is 17.5%).

Submission
-Create a folder with your index number as its name.
-Copy your Java Project folder into the created folder.
-Print a hard copy of your classes.
-Submit both soft copy and hard copy of your project

View Replies View Related

Solving / Roots Of Nonlinear System Of Equations - Java / Android

Oct 11, 2014

I am in search of a library that has been created in JAVA that can be utilized to solve for roots of a nonlinear system of equations. Each equation has 2 variables, x and y, and will need a library that uses higher calculus equations. No ones that just solve for x.

Most of the libraries that have been created to solve nonlinear equations are either in Fortran, C, or Python. There are a few libraries such minpack/scipy. The only libraries that I have been able to find or programming solutions that are in JAVA either require additional programs such as Matlab or are commercial products

I did find one library put together by a professor in Colorado State, but am unsure how to use it. There does not seem to be a way to enter your functions in the code.

Newton Raphson Method - Multivariable(x and y) Page Not Found

How to use this library or find a library that can be used in an android application would be amazing.

View Replies View Related

How Does Program Know To Calculate For Only One Year

Mar 26, 2015

how does the program know to calculate for only one year?

public class Interest2 {
public static void main(String[] args) {
double principal; // The value of the investment.
double rate; // The annual interest rate.
double interest; // The interest earned during the year.

[code]....

View Replies View Related

Program To Calculate Area Of Circle

Mar 11, 2015

I'm starting with my version of very basic program: calculating area of circle. And of course it doesn't get well. My question: what is wrong in this code?

public class circleAre{
double radious;
void putData(double radi){
radi = radious;

[Code] .....

View Replies View Related

Cannot Get Average Program To Calculate Properly

May 9, 2010

I am having a problem with my program. I can't get my program to calculate properly. Everything compiles and run but its just giving me a wrong answer. I am suposse to get 115.50 but instead I am getting .30...

order.java
public class Order
{
double salesTaxRate; //initializing a variable for the sales tax rate.
double subTotal; //initializing a varliable for the sub total.
double shippingCost; //initializing a variable for shipping cost.
double salesTax; //initializing a variable for sales tax.
double totalCost; // initializing a variable for totale cost.

[Code] ....

View Replies View Related

Java Program To Calculate Diameter?

May 6, 2014

Assume the tanker is a cylinder of length 19.35 feet and volume 1320 gallons. What is the diameter in feet of the tanker truck? To solve this problem, write a Java program to calculate the diameter. For full credit, your Java application must follow these specifications.

1. The program must interactively input the capacity of the tanker in gallons and its length in feet. This should be done in the main method of your Tester class.

2. The input data should then be used to construct a TankerTruck object. You will need to write the TankerTruck class.

3. A TankerTruck method should be used by main to calculate the resulting diameter of the truck in feet.

4. Your program should use the standard Java constant for the math constant PI.

5. The output should be displayed using fixed-point notation, rounding to one decimal place of precision

View Replies View Related

Calculate Rainfall Quarterly Program

Mar 29, 2015

//calculates rainfall quarterly program
 
import java.util.Scanner;
 public class SophiaKeyProgram1 {
 public static void main(String[] args) {
// TODO Auto-generated method stub
int numQuarter; //number of quarters in a year
double rainfall=0; //the amount of rain

[Code] ....

I have everything but the min and max numbers.

View Replies View Related

Create Little Program Which Enter Number / Program Says Triangle Exist Or Not

Mar 16, 2014

i want create little program which enter the number, ant program says triangle exist or not. So code :

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

[code]...

So when i put first num like 1, next num like 2 and next num like 100 , program says Triangle exist.

View Replies View Related

Java Program Method To Calculate Distance

Feb 20, 2015

Write method distance, which calculates the distance between two points (x1, y1) and (x2, y2). All numbers and returned values should be of type double. Incorporate this method into an program that enable the user to enter the coordinates of the points, then calculate and display the distance by calling the method –distance.

I've tried numerous times to make it work and I'm on the right path, however I'm missing some things in the code to make my results look like this later on, which I've attached onto this post.

View Replies View Related

Program That Calculate Change Due To Customer By Denomination

Sep 20, 2014

write a program that calculates the change due to a customer by denomination; that is, how many pennies, nickels, dimes, etc. are needed in change. The input is to be purchase price and the size of the bill tendered by the customer($100, $50, $20, $10, $5, $1).

View Replies View Related

Write A Program Using Loop And Break To Calculate Value Of Pi

Oct 5, 2014

having some trouble doing this. Here are the requirements:

1)Write a program using loop and break to calculate the value of PI.
2)You can use the following equation to calculate PI. PI=4/1-4/3+4/5-4/7+4/9-4/11+4/13 etc.. The program shouldn't loop until the criteria is satisfied.
3)The criteria is the value of PI you get is very close to the “real” value (3.1415926), meaning that their difference
should be smaller than a very small numeric number, e.g., 0.0001).
4)The control structures you may need for this program are loop, if-else, and unlabeled break.
5)The output should have the format: for each iteration, it has iteration number and the corresponding value of PI until that
iteration. The last line would be the final value of PI.

Here is my code so far:

package ids;
public class IDS {
public static void main(String[] args) {
double pi = 0;
for(int i=1; i<=100000; i++){
if ((i%2)==0){
pi+=(4/(2*i-1));

[code]...

View Replies View Related

Creating Program With Constructors And Calculate Result

Feb 11, 2015

The end result is when I print the total it comes out to be 0. Trying to solve this

package pay;
import java.util.*;
public class manager
{
public manager(String string, int i, String type) {

[Code] ......

View Replies View Related

Program Will Not Calculate Or Print Out Intersection And Difference

Nov 19, 2014

I have to use methods and loops to code this program. Cannot use any java set or any built in java shortcuts!

import java.util.Scanner;
public class setPractice {
public static Scanner kbd;
public static final int MAXSIZE = 20;
public static void main(String[] args) {
kbd = new Scanner(System.in);

[Code] .....

This is the input I put in my code and this is the output:

How many numbers will be in the 1st set: 3

Enter list of integers for 1st set:
34
2
56

The ascending order for 1st is:
2
34
56

How many numbers will be in the 2nd set: 4

Enter list of integers for 2nd set:
56
2
33
6

The ascending order for the 2nd set is:
2
6
33
56

The intersection of the two sets is: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

The difference of A-B is:

View Replies View Related

Java - Compute PI Using Equation

Oct 24, 2014

Part 1: USING A WHILE OR A DO-WHILE LOOP write a program to compute PI using the following equation:

PI = 3 + 4/(2*3*4) - 4/(4*5*6) + 4/(6*7*8) - 4/(8*9*10) + ...

Allow the user to specify the number of terms (5 terms are shown) to use in the computation. Each time around the loop only one extra term should be added to the estimate for PI.

Alter your solution from part one so that the user is allowed to specify the precision required between 1 and 8 digits (i.e. the number of digits which are correct; e.g. to 5 digits PI is 3.14159), rather than the number of terms. The condition on the loop should be altered so that it continues until the required precision is obtained. Note that you need only submit this second version of the program (assuming you have it working).

My output for part 1 is :

Enter number of wanted terms for value of PI
100
PI = 3.1666666666666665 Number of Term = 2
PI = 3.1333333333333333 Number of Term = 3
PI = 3.145238095238095 Number of Term = 4
PI = 3.1396825396825396 Number of Term = 5
PI = 3.1427128427128426 Number of Term = 6
PI = 3.1408813408813407 Number of Term = 7
PI = 3.142071817071817 Number of Term = 8
PI = 3.1412548236077646 Number of Term = 9
PI = 3.141839618929402 Number of Term = 10 ................ and so on

I know you have to compare value of current Pi to the previous one but I'm stuck.

View Replies View Related

Program That Calculate Minimum Fixed Monthly Payment

Jun 11, 2014

I want to Write a program that calculates the minimum fixed monthly payment needed in order pay off a credit card balance.

the Amount is 3,500 the annual rate is 9.9%, the minimum payment is 2% a month. the fixed payment is 150.

By a fixed monthly payment, we mean a single number which does not change each month, but instead is a constant amount that will be paid each month.

The program should print out :

payment information:
new balance total .......
current payment due .......

if you make minimum payment (2%) you will pay of in .... months and you Will end up paying an estimated total of $........

if you make the fixed rate payment, you will pay of in .... months and you Will end up paying an estimated total of $........ and you will save $........

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved