Converting Positive Binary Inputs Into Hex - Unexpected Output Java

Sep 30, 2014

I am trying to write a program for converting positive binary inputs into hex. in the hex output the point (".")is missing.

Suppose my expected output is e7.6 , but i am getting e76

only the "." is missing.

here is my BinToHex class..

import java.io.*;
public class BinToHex {
double tempDec,fractionpart;
long longofintpart,templongDec;
String input ="11100111.011";
String hexOutput=null,tempDecString,hex = null;
static int i = 1;

[Code] ....

View Replies


ADVERTISEMENT

Program For Converting Positive Binary Inputs Into Hex - Unexpected Output Java

Sep 30, 2014

I am trying to write a program for converting positive binary inputs into hex. in the hex output the point (".")is missing.

Suppose my expected output is e7.6 , but i am getting e76.

Only the "." is missing.

Here is my BinToHex class..

import java.io.*;
public class BinToHex {
double tempDec,fractionpart;
long longofintpart,templongDec;
String inpu ="11100111.011";
String hexOutput=null,tempDecString,hex = null;
 
[Code] .....

Here is how decimal fraction is converted into hex or here too...

View Replies View Related

Write A Program For Converting Positive Binary Inputs Into Hex

Sep 29, 2014

I am trying to write a program for converting positive binary inputs into hex.Why am i getting this errors while compiling my binary to hex converter..

Exception in thread "main" java.lang.NumberFormatException: For input string: "148.0"
at java.lang.NumberFormatException.forInputString(Num berFormatException.java:65)
at java.lang.Long.parseLong(Long.java:441)
at BinToHex.convertbintohex(BinToHex.java:24)
at Test.main(Test.java:4)

Here is my BinToHex class

import java.io.*;
public class BinToHex {
double tempDec,fractionpart;
long longofintpart,templongDec;
String inpu ="1001.01";
String hexOutput,intpart,tempDecString,hex = null;

[code]....

View Replies View Related

Creating A Thread - Unexpected Output

Mar 18, 2014

Java Code:

package Threads;
public class Threads1 implements Runnable {
public void run(){
System.out.println("
* * * * *
");
}
public static void main(String[] args) {

[code]...

Java Code:

new Thread(new Threads1()).start(); mh_sh_highlight_all('java');

should execute the thread associated with the run() and then the control should return to the next statement in the calling thread (the thread from which the other thread (associated with run()) was called); isn't it?

View Replies View Related

How To Save Results / Inputs For A Binary Search Algorithm

Apr 24, 2014

Is there a way that I can save a binary search algorithm to a text file or something, so that it will always contain more information? The reason why I ask this is because I have BST like project which is supposed to act the game Twenty Questions, were it asks a person 20 Q's until it guess the answer. However, although my project does not require you to save stuff to a file, I find it rather very useful and cool if I could do that.So for example it would start out something like this:

Think of an animal and I will guess it.
Does it have legs? YES
Is it a cat? YES
I win! Continue? YES

Think of an animal and I will guess it.
Does it have legs? NO
Is it a snake? YES
I win! Continue? YES

Think of an animal and I will guess it.
Does it have legs? NO
Is it a snake? NO
I give up. What is it? EARTHWORM
Please type a question whose answer is yes for an earthworm and no for a snake.
DOES IT LIVE UNDERGROUND?
Continue? YES

Think of an animal and I will guess it.
Does it have legs? NO
Does it live underground? NO
Is it a snake? NO
I give up. What is it? FISH
Please type a question whose answer is yes for an earthworm and no for a snake.
DOES IT LIVE IN WATER?
Continue? NO
Good-bye.

However, if the user exits the program then everything will be lost and go to waste. So once again, is there a way that I can save all of these inputs to a file or something and then read it in again?

View Replies View Related

Converting User Input Binary To Integer

Sep 7, 2014

I am new to java and programming in general. I figured out how to convert an integer input to binary however I am having issues doing the opposite of converting a user input binary number to a decimal.

I need to do this with basic math (or string depending on how I represent the binary) and no functions.

I know how to convert binary to integer on paper but I am having a hard time working it out in java.

View Replies View Related

User Inputs His Full Name In A String From Keyboard / Program Will Give His Initials As Output

Jan 5, 2014

Following is the code for my assignment where a user inputs his full name in a string from keyboard. It should be done using BufferedReader. The program will give his initials as output.

############################

For example: User inputs-> Ram Kumar Das

Program Returns-> R.K.D.

I am written the following piece of code. It does not return the correct output. If "Ram Kumar Das" is given as input, it gives R.K.K. as output. Arrays and objects are strictly not allowed.

Java Code:

import java.io.*;
public class Assignment
{
static int i=0;
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static void main (String args[]) throws IOException

[Code] ....

View Replies View Related

Manual Code For Converting Binary Octa / Hexa And Decimal

Aug 25, 2014

There's a main menu choosing binary,octa,hexa,and decimal if i choose decimal it will display decimal menu and then i will input the numbers of binary and then it automatically display the converting process for octa hexa and decimal. and if i choose octa . It display the octa menu and i will input the numbers in octa and then it automatically display the converting process for binary hexa and decimal.. and so on.. but in binary if i input 2 it will display invalid .. the same as octa hexa and decimal... in my code the only problem is the converting process. our instructor said no one will use a converter for our project. we will code it manually ..so for a moment .. this is my code..

import java.util.*;
import java.lang.*;
public class mainmenu {
public static void main (String[]args) {
Scanner in = new Scanner(System.in);
char B, O, H, D, Q, L, N , Y;
char bin , pk, pick ;

[code]....

View Replies View Related

Converting From Decimal To Hexadecimal - How To Output Correctly

Feb 24, 2014

import java.util.Scanner;
public class FindHexString {
public static void main(String[] args) {
String hexString = ""; //output a hex string
int decNumber;//decimal number to be converted
int storeInput; //copy f input decimal number

[Code] ....

I am trying to figure out how to convert from decimal to hexadecimal without using the java library function. This is just a guess. I could be wrong.

View Replies View Related

Converting The Output Of Table To Float Point Value

Apr 26, 2015

I created this program to display a square root table. Problem is all of my output is too long. I would like to round the number to 4 spaces past the decimal. Here is my code:

public class MySqrt5_2 {

public static void main(String[] args) {
System.out.println("Number SquareRoot");
int[] table;
table = new int[21];
for (int counter = 0; counter < table.length; counter += 2) {
System.out.println(counter + " " + Math.sqrt(counter));
}
}

}

View Replies View Related

Write A Java Program That Reads A Positive / Non-zero Integer As Input

Aug 1, 2011

Write a Java program that reads a positive, non-zero integer as input and checks if the integer is deficient, perfect, or abundant.

A positive, non-zero integer, N, is said to be perfect if the sum of its positive proper divisors (i.e., the positive integers, other than N itself, that divide N exactly) is equal to the number itself. If this sum is less than N, the number is said to be deficient. If the sum is greater than N, the number is said to be abundant.For example, the number 6 is perfect, since 6 = 1 + 2 + 3, the number 8 is deficient, since 8 > 1 + 2 + 4, while the number 12 is abundant, since 12 < 1 + 2 + 3 + 4 + 6.

SAMPLE OUTPUT:

1.)Input N: 5

5 is deficient.

2.)Input N: 6

6 is perfect.

3.)Input N: 18

18 is abundant.

View Replies View Related

Java Code - Multiple Execution Of Jar File With Different Inputs

Jan 4, 2014

I would like to ask you how can i execute the next code without errors.

I am trying to execute a jar (myFile.jar) file multiple times with different inputs from another jar file. More simple i have game with many players and i create a Round Robin scheduling for the tournament, i need to execute all the mach's of a round together.

When i run the next code it execute on the first game with the first players multiple times.

Java Code:

public class RunJARFile {
//10 player
//5 game per round
public static void main(String[] args) throws IOException {
for (int Tour = 0; Tour < 9 ; Tour++) {
for (int Game = 0; Game < 5; Game++) {

[Code] ....

View Replies View Related

Increment Array And Got Unexpected Result

Aug 16, 2014

Java Code:

char array[] = new char[10];
int i = 0;
array[i++] = (char)('A' + i);
System.out.println("char for array is: " + array[0]); mh_sh_highlight_all('java');

However, the result for array[0] is B. Not A. from my understanding, the array[0] should be 'A'.

View Replies View Related

Unexpected OpenGL Simple Movement

May 28, 2014

I am new to DreamInCode! I was creating a game using OpenGL (and slick for textures).

Using Vector3f, I make coordinates to where my camera is camera'ing (and rotation).

It was working... until I modified something. I only added shaders. When I took the shaders off I think I might of accidentally deleted something. Nonetheless the code looks perfect to me.

On the method "input()" everything runs. No errors are thrown anywhere. I have syso'd the hell outa my code. It shows no signs of breaks. I can, however, move elements I put into my program. I am 100% sure that no other class is breaking my game (soon to be).

What you should look out for: I am not really sure about the glLoadIdentity()'s and glMatrixMode(). I am, knowing a good part of, thinking it could be gluViewPort....

My problem: Can't move my camera even tho it was working before.

package com.Hydroque.OpenGlTest;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.util.glu.GLU.gluPerspective;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;

[Code] ....

View Replies View Related

Increment Array And Got Unexpected Result

Aug 16, 2014

char array[] = new char[10];
int i = 0;
array[i++] = (char)('A' + i);
System.out.println("char for array is: " + array[0]);

However, the result for array[0] is B. Not A. from my understanding, the array[0] should be 'A'.

View Replies View Related

Unexpected Type - A Returned Variable Required

Apr 2, 2014

I'm making a Hangman program for Java, here's my code:

import java.util.Scanner;
public class Hangman {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String answerWord = WordList.getWord();

[Code] .....

The Compiler gives me this only error:

Hangman.java:39: error: unexpected type
displayWord.charAt(i)=userInput.charAt(0);
^
required: variable
found: value

I understand that charAt returns i as a value and not a variable. What do I use to return a variable as I intended?

View Replies View Related

JSP :: Converting ASP To Java

Dec 22, 2014

I'm converting from ASP to Java for a legacy site. I believe the first part of the if statement is right but I'm having an issue within the else staetment. I'm getting date is undefined, I've tried using getYear and getDate but have not been successful.

ASP:

If Request("action") = "results" Then
aMonth = Request("selMonth")
aDate = cint(Request("selDate"))
aYear = cint(Request("selYear"))
Else
aMonth = UCase(MonthName(Month(Date()),true))
aDate = Day(DateAdd("d",-1,date()))
aYear = Year(Date())
End If

[code]....

View Replies View Related

Converting Into Unicode Using Java

Jan 28, 2014

This is the code to convert string into unicode but I get an error as "illegal start of an expresssion"while running the code..

import java.util.Scanner;
import java.lang.String;
import java.lang.Character;
public class A
{
public static void main(String args[])
{

[Code]...

View Replies View Related

Converting Java To Exe Error

Oct 5, 2014

I compiled a java program and converted it to an exe file and it works fine on the computer I created the java file in but when i try it on another computer it gives me a "Java Virtual Machine Launcher - A Java Exception has occured" error message.

View Replies View Related

IWAB0014E Unexpected Exception Occurred In Web Service Sample Program

Apr 8, 2014

I first time tried Java web service sample example using eclipse with axis2. First i wrote the provider class. Then by clicking create Web Service from the provider class It will show the following error "IWAB0014E Unexpected exception occurred." I have attached the screenshot for reference.

View Replies View Related

Converting Math Formula To Java?

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

Converting Longblob From MySQL To Java

May 13, 2015

I wanted equivalent datatype of  longblob in java ...

View Replies View Related

Java Program That Will Ask A User To Input Grades Until User Inputs Sentinel Value

Apr 9, 2014

Write a java program that will ask a user to input grades until the user inputs the sentinel value -1. The program should test each input to determine whether 0<=grade<=100. If the grade entered is within this range, the program should print "Grade accepted;" if not, the program should print "Invalid input".

View Replies View Related

Write Data For Three Products To Random Access File - Unexpected EOFException

Jul 11, 2014

I'm trying to write data for three products to a random access file, but I have a problem. Each product has a code and a price. After writing them to my file, I want to get to the second field or product. I do this by getting the length for each record, and multiplying it by the field number I want to go to. I use the result for the seek() method of the RandomAccessFile object. It is giving me an EOFException, but when I use 0 for the seek method i get the data for the first poduct or field.

Java Code:

public static void main(String[] args) {
final int RECORD_LENGTH = 16;
try(RandomAccessFile productsOutput = new RandomAccessFile("C:UsersalfonsoDesktopBinaryTestRandom.ran", "rw")) {
String[] codes = {"java", "jsps", "txtp"};
double[] prices = {49.5, 19.9, 29.9};
for(int i = 0; i < codes.length; i++) {

[Code] .....

View Replies View Related

Converting Pseudo-code Into Java Language?

May 12, 2015

I am trying to use a for loop for getting hours for an employee for five days. how to convert my pesodocode into java language so that it will compile. This is what my pesodocode looks like:

begin getHours()
for(index=0; index <5; index++)
get hours **System.out.println()
**inputString = input.readLine()
**plumbersHours[index] = plumbersHours [index] = integer.parseint(inputString)
endfor
index = 0
while (index < 5)
totalHours + = plumbersHours[index]
index++
end while
return

View Replies View Related

Converting Range Statements To Sets In Java

Mar 20, 2014

I am trying to Extract the ranges of Variables from a Text File. I extracted lines of the forms X in 1..10 Y in 12..50 Z in 0..19 / 66/ 95..100 Where X in 1 ..10 states that X takes values from set 1 to 10 Similarly for Y and for Z its a Union of different ranges of the values (0 to 19, union 66,union 95 to 100)

I want to Map these Variables to their respective sets using Hashmap where Key is Variable name and value will be a Set. My Hashmap Signature is HashMap> hm=new HashMap>();

Java Code:

while((line=br.readLine())!=null) {
Matt=Patt.matcher(line);
if(Matt.find()) {
//System.out.println(line);
String []s=line.split(" ");

[Code] .....

I am stuck at extracting the variables ranges from these plain strings.

View Replies View Related







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