I'm stuck trying to figure out why this isn't compiling.
Bumper.java:87: error: possible loss of precision
myX = (Math.random()* (rightEdge-myXWidth) + myXWidth / 2);
^
required: int
found: double
Bumper.java:88: error: possible loss of precision
myY = (Math.random()* (bottomEdge-myYWidth) + myYWidth / 2);
^
required: int
found: double
I was asked to write code to calculate a person's calories burned/min. This is what I got. The problem is I keep getting an error.
--------------------Configuration: <Default>-------------------- C:Program FilesJavajdk1.7.0_72CaloriesBurned.java:22: error: possible loss of precision caloriesBurnedPerMinute = 0.0175 * METS * weightInKg; ^ required: int found: double 1 error
Loss of precision? What does that mean? Do I have to change weightInKg into some other number type?
import java.util.Scanner; public class CaloriesBurned { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); int runningHours, basketballHours, sleepingHours, METS, caloriesBurnedPerMinute;
I am teaching myself Java and am trying to write a function that will determine all of the perfect squares between 1 and 100 but am running into a problem...
Here's my code:
package sqrroot;
public class SqrRoot { /** * @param args the command line arguments */ public static void main(String[] args) { double sroot, rerr; int count = 0; for(double num = 1.0; num <= 100.0; num++){
[Code] ....
and here is the output:
run: 0.0 1.0 is a perfect square. 0.0 4.0 is a perfect square.
[Code] ....
There are 49 perfect squares between 1 and 100. BUILD SUCCESSFUL (total time: 6 seconds)
Which is clearly wrong. Is there something wrong with my code or is this due to inherent imprecision in the double type or the Math.sqrt function?
The authenticatedUser and menu attributes are gone. I never know when it's going to happen so I can't trace it. Any guesses why those type session objects would die?
I attached an image of what menu object looks like.
public void draw(ArrayList<int[]> good,ArrayList<int[]> bad){ drawing = true; goodToDraw=good; badToDraw=bad; System.out.println("Canvase/draw: Calling paint with a size of "+goodToDraw.size()); middleMan();
[code]....
What this does is two ArrayList are sent to the draw function.one called good and the other bad. Right now I am only working on good. What is suppose to happen is paint takes all the good coordinates and paints them but I seem to loose the arrayList size when repaint is called. You can see in the picture below of my console that it starts of with 20. Then because I was wondering if the scope was to short i called middleman to make sure that it held its size outside of the first function. Then finally it calls paint and tells me the array is empty. To simplefy..Why does my arraylist size go to zero when I call repaint?
I am still new to Java and have an assignment that I am stuck on. I believe I got the boolean function correct, however I cannot figure out what to write in the main function. I have exhausted searching, and trying different loops, arrays, etc.
Ok, so in my quest to achive perfect ray casting and line/plane intersection, what I believe to be my last problem is precision of a float. I need some precision (0.000) but I am dealing with the difference of (-1.000000000) and (-1.000000002), where the second number would be completely off. I looked at DecimalFormat, but that just puts it into a string, I need actual loss of precision.
Java Code:
DecimalFormat form = new DecimalFormat("0.00"); String newX = form.format(x); String newY = form.format(y); String newZ = form.format(z); x = Float.parseFloat(newX); y = Float.parseFloat(newY); z = Float.parseFloat(newZ); mh_sh_highlight_all('java');
I am trying to write a small program that will calculate the gain and/or loss of the sale of stock. The program will ask the user for the number of shares, the purchase price and the selling price. I am pretty sure that the errors is coming from my calculations in the program.
import java.util.Scanner; public class investmentCalculator { public static void main (String[] args) { Scanner input = new Scanner(System.in); //User input for number of shares System.out.print("Enter the number of shares: "); double shares = input.nextDouble();
I have run into a bit of a head scratcher, at least to me. I am building multiple rectangles using double precision. I had to switch from int to double due to another issue that requires decimal places. Now, my fillRect (last line in the code section I posted) is causing an error as it only wants to work with int.
public void draw(Graphics2D g2) { // check that sizes are above 0 if ((rectWidth <= 0) || (rectHeight <= 0))
I have code for precision and recall testing for search engines. I am trying to run it in Newbeans 8.0, but I am getting the common error in UnsupportedOperationException
I have tried making files and directories as the given in the code file. I am attaching the two files here.
For my jsp file, the code editor shows no error, but the projects window shows an error. I built my project again, cleaned the project, restart eclipse twice and summoned cthulhu. But my project still shows an error. How do I find the cause.
Eclipse project -
JSP file -
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@ taglib prefix="mine" uri="DiceFunctions"%>
<%@ page language="java" isErrorPage="true" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Error</title> </head>
[code]...
I have put error.jsp and badpage.jsp file in public access folder that is web content in eclipsewhen I am running the code I am status code of 500 and not the errorpage.jsp message .
I need to compile a JAVA code to call a web service. The web service provider gave me this sample code, but compiling with javac i have one error for each row of code.
import java.util.Scanner; public class Pract3CQ2 { public static void main(String [] args) { Scanner keyboardIn = new Scanner (System.in); //Declare variables int a=20, b=10, diff;
I am getting a NullPointerException Error and I cannot seem to figure out what is causing it. I am reading in a grades1.dat text file and putting the values into a 2D array. The error is occuring in my addGrade method, but I am not sure what the error is. Here are the values for my grades1.dat that I am running in through Run Arguments in JGRASP.
Student1 5 a Activities 0.05 q Quizzes 0.10 p Projects 0.25 e Exams 0.30 f Final 0.30 a100 a95 a100 a100 a100 q90 q80 q100 q80 q80 r90 p100 p95 p100 p85 p100 e77.5 e88 f92
Here are the errors that I am getting.
Exception in thread "main" java.lang.NullPointerException at GradeBook.addGrade(GradeBook.java:114) at GradeBookApp.main(GradeBookApp.java:55) import java.util.Arrays; /** * Stores students name, a char array of category codes, a String array of categories, a double array of category weights, and a two dimensional double array of grades where each row contains all the grades in a particular category.
I am having a error in progress bar ... I want to see the progress upon checking the sha1 of files
This is the code:
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package program1;
Exception in thread "Thread-2" java.lang.NullPointerException at program1.ProgressBar$thread1.run(ProgressBar.java:98) at java.lang.Thread.run(Thread.java:744)
So I am working on a school project and I have 2 classes, class FakeGravity contains all the properites and class BouncyBall is my driver class. For some reason when I try writing
FakeGravity gravity = new FakeGravity( );
I get an error. I am attaching an image of the error, and also attaching the program just in case you need more information. Also I was using blueJ to write the program
dcasarrubias, on 27 October 2014 - 02:44 PM, said:
So I am working on a school project and I have 2 classes, class FakeGravity contains all the properites and class BouncyBall is my driver class. For some reason when I try writing
FakeGravity gravity = new FakeGravity( );
I get an error. I am attaching an image of the error, and also attaching the program just in case you need more information.
I am using netbeans 7.2, glassfish 3.1.2, JSF 2.1 and Primefaces 3.2. When I add more than three menu tabs, I get this error ui layout initialization error the center-pane element does not exist the center-pane is a required element. This is my template.xhtml code:
<?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui">