I'm having some trouble with a code I am writing for class. I had an 2 errors like this before this one and fixed it by changing int avgRe, avgMiles =0; to double. Now I am getting this error and am stuck on what I need to change. Here is the code:
import java.io.*;
import java.util.*;
import java.text.*;
public class Reimbursement_3_09 {
static Toolkit tools = new Toolkit();
public static void main (String [] args) throws Exception {
[Code] ....
This is my error:
[code=Java]
Reimbursement_3_09.java:33: error: incompatible types: possible lossy conversion from double to int
summary (outFile, totalAmount, ctrMiles, ctrMilesgt0, avgRe, avgMiles);
^
Some messages have been simplified; recompile with -Xdiags:verbose to get full output 1 error
I am trying to convert the double 4270571936.0000000000d to a hex string using Double.toHexString() and the answer I'm getting is 0x1.fd17834p31, what does p stands for?
The answer I'm expecting to get is 0x41efd17834000000 so not sure why it won't give me the correct answer?
The following floating point Double to hex calculator shows the write answer right Floating Point to Hex Converter
I have a char[] containing ASCII characters that need to be converted into int value and double value.
The int value are always stored in 1 char size like 'j'. I extracted it succesffully by converting the char in a ascii bytearray and then used: Integer.parseInt(sb.toString().replace("0x", ""), 16);
How can I get the Value as double when i used the char[] with size 2 or 4 ?
Example : final char[] charValue = { 'u', ' ', '}','+' }; what is the associate Double value ?
Example : final char[] charValue = { 'T', ' ' }; what is the associate Double value ?
Example : final char[] charValue = { 'T', ' ' }; what is the associate int value ?
I am working with a java program that uses binary and sequential search. i have those two methods working. In the program i also need to return the price of parallel arrays. This is my code so far:inventory class:
//FileName: InventoryData.java //Prog: Brock Paston //Purp: To load and search through arrays with binary and sequnetial search. package stu.paston.program6;
When I try to convert this value, "Testingu2120" (along with UTF coed u2120)comes as a string as part of SOAP response. I need to convert this UTF-8 characters in to a symbol, in this case it is SM (Service Mark) symbol and show it on the UI.
How can we achieve this in JAVA?
I have four different UTF-8 character set to convert.
I need to convert the LDIF data file to CSV format using Java. IS there any supporting JAR's, which we can use for the LDIF data file reading and parsing. Which is the best jar to use.
final ServerSocket serverSocketConn = new ServerSocket(9000); while (true) { try { Socket socketConn1 = serverSocketConn.accept(); new Thread(new ConnectionHandler(socketConn1)).start();
[Code] .....
I managed to convert this final DatagramSocket serverSocketConn = new DatagramSocket (9000);
Now I am stuck here
Socket socketConn1 = serverSocketConn.accept(); new Thread(new ConnectionHandler(socketConn1)).start();
Can I use this or I need to create a manual thread pooling for UDP ?
Case study : infix to postfix conversion, i don't really know how i could make codes, I can understand what is the meaning of infix and postfix but when it comes of making codes i really have a hard time with it.
but when I put this second line, the conversion, the program stops to work. I tried also with Integer.valueOf(timeInterval) but again I had the same problem.
I'm working on a Weight Conversion program. The code I have for the program is:
import java.util.*; import java.awt.*; import javax.swing.*; public class Frame4a implements ActionListener { public static void main(String[] args) { JFrame f = new JFrame("Weight converter"); JPanel P = new JPanel(); // Make a JPanel;
[Code] .....
The errors I'm getting are:
Frame4a.java:33: error: class, interface, or enum expected public void actionPerformed(ActionEvent e){ ^ Frame4a.java:37: error: class, interface, or enum expected double kp= Double.parseDouble(strkilo);
why i cant get the return value to my conversion class.
import java.util.*; /* * * public class MetricTest { public static void main(String[] args) { Scanner input = new Scanner(System.in); // declare a sentinal to exit the loop String check = "Quit";
If I don't append the L, is the msb (most significant bit) somehow still carried over to the resulting long variable and in the latter case, where I append an L, it is not and instead the value is filled up with 32 leading zeros (4 Byte difference between int and long)?
I'm having trouble getting the text entered in my JTextField to be converted to the conversion formula. The line I'm getting error in is:
String text = text.getText();
Also I created another JTextField in which I want the answer to be displayed in, but I'm not too sure how to go about that. This is my attempt at it, but it doesn't work because it doesn't make sense; result.setText1(Integer.toString(celsius));
import java.awt.*; import javax.swing.*; import java.awt.event.*; public class TempConversion extends JFrame { private final JLabel ask; private final JLabel result; private final JTextField text; private final JTextField text1;
I have followed the instructions carefully but the conversion values are not correct.
Write a program that displays a table of the Celsius temperatures 0 through 20 and their Fahrenheit equivalents. The formula for converting a temperature from Celsius to Fahrenheit is F - | C + 32 where ¥ is the Fahrenheit temperature and C is the Celsius temperature. Your program must use a loop to display the table.
Code
public class TempConversion { public static void main(String[] args) { for(double i = 0; i <= 20.0; i++) {
The problem when I run this code is that during conversion, the decoder or encoder seems to drop a good deal of black. I'd like to include examples, but the tiff images are about 30 MB...I've tried configuring the decode parameters, as well as the encode parameters, but like I said, somewhere during conversion I drop a good deal of the black from the image.
I have made a program that is supposed to convert roman numerals to decimals. It is NOT supposed to convert decimals to roman numerals. The only problem it seems there is with the program is that it only adds and does NOT subtract. This causes some roman numeral conversions to be flawed. What can I try to fix this. Keep in mind that the reason some methods exist is because the directions for the code say that I have to make it this way.
Instructions:
Write a program that converts a number entered in Roman numerals to decimal. Your program should consist of a class called Roman. An object of type Roman should be able to do the following:
1) Store the number as a Roman numeral. 2) Convert and store the number into decimal. 3) Print the number as a Roman numeral or decimal number as requested by the user. (Be sure to over-ride the toString function). 4) Your class must contain the method romanToDecimal to convert a Roman numeral into its equivalent decimal number. 5) Test your program using the following Roman numerals: MCXIV, CCCLIX, and MDCLXVI.
This is what I have so far. It compiles and there are no errors, but it does not subtract I from X, or I from V and so on. For example,CMXLVII should be 947, but the program outputs 1067.
import javax.swing.*; import java.util.*; public class Roman{ private String roman; private int decimal; public int romanToDecimal(String s)
So, here is the question I have been working on: Write a java class named Time that prompts the user to input the elapsed time for an event in seconds. The program then outputs the elapsed time in hours, minutes, and seconds. (For example the elapsed time is 9630 seconds, and then the output is 2:40:30 ).Hint: an hour has 3600 seconds and a minute has 60 seconds. Use Scanner class for reading the input.
Here is my code:
import java.util.Scanner; public class Time { public static void main(String[] args) { Scanner scan= new Scanner(System.in); System.out.println("Enter the elapsed time in seconds:"); int totalseconds= scan.nextInt();
[Code] .....
Now, I know I am supposed to use the remainder operator to figure out the time in minutes and seconds, but the hours has be a little confused. Right now this code compiles but gives me an exception.