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 ;
The code here I have works fine if I just want to ask the user to enter four digits: //java application that asks user to input binary numbers(1 or 0) and convert them to decimal numbers import java.util.Scanner; //program uses class scanner public class binarynumber{
//main method that executes the java application public static void main(String args[]){ //declares variables
int digit; int base=2; int degree; double decimal; int binary_zero=0; int binary_one=1; //create scanner for object input
[code]....
The thing is, I want the java application to input more than four digits for the user and I want it to loop it manytimes f until the user ask it to stop.
I'm trying to complete a code to convert decimal to octal. however i can't figure out how to print the output correctly. it should be.. Your integer number 160000 is 0470400 in octal. (160000 is the number you input). My code is...
Scanner input = new Scanner(System.in);
int value; int a; int b; int c; int d; int e; int f; int g; String result;
[Code] .....
Lastly, my output prints everything correctly, but the input number always is 0.
Ex error: input= 160000
Your integer number 0 is 0470400 in octal.
it should be.. Your integer number 160000 is 0470400 in octal.
I am trying to convert the double grossPay to 2 decimal places but cannot get it to work ,I am unsure of the correct way of doing this but this is how far I can get
I'm having extreme difficulty in working with a Vector storing a column with a BigDecimal value, and converting that single value into a float. I'm not sure why the code was written this way, but basically, I'm working with something called a vector that has a single Big Decimal value/column (not sure what the correct terminology is), and I want to store that value in a float variable called "dp". However, I don't know how to convert from the Big Decimal to a float.
Code is below:
String s = ""; sql = "SELECT DiscountPercentRate FROM Attendees WHERE AttendeeId=" + attendeeId; Vector v2 = sqldb.getResults(sql); /*I know that sqldb.getResults(sql) returns a vector with a single BigDecimal column of 15.0, in the test example I'm using*/ if (!v2.isEmpty()) { Vector data2 = (Vector)v2.elementAt(0); if (!data2.isEmpty())
[Code] .....
In case you're wondering what the sqldb.getResults() method looks, like, here's a snippet of it - There's an else statement that triggers in my case, adding a BigDecimal column to a vector, and returns that vector.
Vector v = new Vector(); ... else { BigDecimal bd = rs.getBigDecimal(i); vCols.add(bd); } v.add(vCols); ... return v;
How can I take the single result of my SQL query in that Vector/Big Decimal thing, and turn that result into a float value?
I do not know how to convert a reversed array to decimal.
The output should be:
How many digits to convert? (user will input) ex. 3 Please input digits: (user will input 3 digits) ex. 0 1 1 The binary digits are: 110 (<-reversed) The decimal value is: 6
Here is my code:
package numbersystemconversion; import java.util.Scanner; public class BinarytoDecimal { static { int digit=0; Scanner input = new Scanner(System.in);
I am having an issue with my program. It is supposed to convert from a binary number to a decimal number such as bin 101 = dec 5. my first and foremost issue is that when I use System.out.println(parseBin("101")); it returns 5 as it should. However when I change 101 to 1013 it returns 13??? Why is this happening and why are my exceptions not catching the issue?
//import java.util.Scanner; public class BinaryFormatException { public static void main(String[] args) throws BinFormatException{ System.out.println(parseBin("1013")); //Scanner input = new Scanner(System.in); //System.out.println("Please enter a binary number using 1's and 0's: "); //String binString = input.nextLine();
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.
I'm working on creating the Binary to Decimal program . hat is wrong with this part of my code. Why does it not take you into the loop.
import java.util.Scanner; public class question5 { public static void main(String[] args) { System.out.println("Enter a Binary number. "); // collect Scanner keyb = new Scanner(System.in); //
This problem is from Java . It asks me to convert a binary number in to decimal. How to program this in java? I am not able to find an effective algorithm to convert in to Java.
I get an error when I try to divide 500 miles by 25.5 gallons
Exception in thread "main" java.lang.NumberFormatException: For input string: "25.5" at java.lang.NumberFormatException.forInputString(Num berFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:580) at java.lang.Integer.parseInt(Integer.java:615) at Mileage.main(Mileage.java:42) Java Result: 1
I am new to java programming and using bluej for programming and i have tried this question what i have have given in title ... How to do the following question without using strings.
Write a java program to input a binary value and convert it into decimal and Vice Versa. Without using String. Please make it for blue j format.
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.
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;
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;
How i would convert this java code to display using the printf statement, with two decimal places to the right...here is the source code so far, but it has a few errors and needs to be reformated for printf
import java.util.Scanner; // scanner class public class PROB3_CHAL15 { public static void main(String[] args) { double checks =0, totalfee =0, fee = 10, fee1 =.1, fee2 = .08, fee3 = .06, fee4 = .04, checkFee; String input; Scanner keyboard = new Scanner(System.in);
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
I have written a code to get all the nodes below a current Node and it is working but I need to get it to look better if possible. To get the number of nodes below I have created an Array List, which I then go to the first Node below and add all the people to the Array list on the same level till I get to the end of the level, then I go down again until I cannot go down any more. Is there a way I can have my code without having to use an array List? I have put my code below. The brieff about the tree is that you have a parent and below the Parent are children who can have brothers and sisters next to them and after that they also have children below that. The method is trying to find the number of children below any given child
private LinkedList<Node> TempQueue = new LinkedList<Node>(); public int noOfYoungerChildren(Member p1){ Node tmp = find(p1); return countYoungerChildren(tmp);
I'm just getting two errors concerning line 38 where it has Arrays.sort(int roomList); and the errors state that ".class is expected" and so is a semicolon. What did I do wrong? Also, how might I tweak the code to display "Occupied" or "Unoccupied" depending on the room that was entered?
Also we're not allowed to make use of API method for binary search so that's out of the question.
import java.util.Scanner; import java.util.Arrays; public class HotelRoom { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); int[] roomList = new int[25]; // occupied rooms
Problem is, the link invokes the doGet method of my servlet and the jsp:forward invokes the doPost. Is it possible to use jsp:forward and specify doGet somehow?
I'm using eclipse. I'm going to get straight to the point and give all the info I can, if the values in the first code box are used, shouldn't these values be left after all in the second box is done:
remainder=23, arr[0]=100, div=23/10=2.3, whole=2, and decimal=3?
When I use this code, div comes out to be just (2.0).
Java Code:
int leng=10; arr[0]=123; //int arr[1]=100; //int mh_sh_highlight_all('java'); Java Code: if (arr[0]!=arr[1]){ int remainder=arr[0]-arr[1]; arr[0]=arr[0]-remainder; double div=remainder/leng; //double div=Double.valueOf(remainder/leng); int whole=(int) Math.floor(div); int decimal=(int) ((div-whole)*leng); mh_sh_highlight_all('java');
I'm not sure were I'm going wrong in how div is being calculated, but I ultimately need div to be 2.3.
I've also used the second option commented out which still gives (2.0).
I was a bit confused of the code generated by the Axis2 Code Gen.
I have created a logIn(String username, String password) method in my service and used Axis2 Code Gen to generate the Stub.
I try to access the logIn method from my Client using the Stub like below:
TestServiceStub stub = new TestServiceStub("http://localhost:8080/axis2/services/TestService"); String test = stub.logIn("user","pass").
but instead of UserName and password as the parameters, the Stub created a Login object as the parameter for the logIn method. like the one below:
stub.logIn(Login login1);
I wanted to try the logIn method by providing a static userName and password but it seems impossible because the Stub changed the parameter for the logIn method.
I need to create a Java program that takes an input a color code in HSV and outputs the equivalent RGB code and Vice versa.
Example: If you test on the color RED in RGB: Input: (255,0,0) Output: (0,100%,100%) If you test on the color RED in HSV: Input0,100%,100%) Output: (255,0,0)