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); //
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();
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 trying to make a translator program that will convert english to my custom binary. It works going from english to binary, but not going from binary to english.
import java.util.Scanner; public class Translator { public static void main ( String [] args ) { Scanner input = new Scanner( System.in ); System.out.print( "Would you like to convert English to Binary (yes or no)? " ); String answer = input.nextLine();
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);
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.
So I have to write a java program that converts hexadecimals to decimals without using the whole "integer.parseInt(AB1, 16)" method. I tried looking up how to do this but every forum/site I went to used this same method.
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 ;
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);
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 am using NetBeans IDE 8.0.2 to program Java code. I am a beginner in Java.
Instead of getting two decimal places after the point, I am getting three despite using the code format for two ("##.##"). Actually, this happens even if I remove the format code between the quotes. It is as if the program cannot see the format code. Why this happens ?
Here is the relevant program code:
private void convertButtonActionPerformed(java.awt.event.Action Event evt) { double inputNumber = 0; // sets the decimal format
I'm trying to convert an octal number into a decimal number. I keep getting a big error that says java:63: error: class, interface, or enum expected. i need to use a public static int convert ( int octalNumber ) along with a public static void main ( String args[] ).
Here is my code. />
[public static void main ( String args[] ) { int foo; int valid = 0; Scanner sc = new Scanner (System.in); System.out.print ("Enter up to an 8-digit octal number and I'll convert it: "); foo = sc.nextInt();
so I need my program to print in decimal format and I keep getting an error saying that it cant find symbol "decimalFormat". here's what I have so far.
import java.util.Scanner; public class GPACalculator { public static void main(String[] args) { int creditHours = 0; int gradePoints = 0;
How do I get the code to use decimals? Also whenever you input 1, 2 or 3 as one of the operators, it always does that operator as well as the 4th operator at the end. So it always does subtraction. However when you use 4 as the only operator it works perfect.
import java.util.Scanner; public class Program05 { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); double left; double right;
I know how to do this program it is just not coming to me. The whole point is to calculate and display the base (base-2 or binary, base-8 or octal and base-16 or hexadecimal) in representation of 'N'. The symbols A, B, C, D, E, F should display 10, 11, 12, 13, 14, and 15 in hexadecimal system.
import java.io.*; import java.util.Scanner; public class ChangeBase { public static void main(String[]args) { double num;
I'm having trouble formatting my output and issues with the decimal places. Here's my code:
import java.util.Scanner; import java.text.DecimalFormat; // Imports DecimalFormat class for one way to round public class lab3 { public static void main(String[] args) { String heading1 = "Hour", heading2 = "Distance Traveled"; int timeElapsed, hour, speed;
[Code] ....
And here's my output (Click on the image since it's pretty small):
javaIssues.png
Issue: 1) The Hours 2 and 3 aren't aligned to 1. 2) The 80 and 120 in Distance Traveled have 6 decimal places when it should not have decimals.
Ex. If I type 5943, the program will say mill = 5 hun = 9 ten = 4 uni = 3
get the picture I had to translate the decimal value names from a different language.
This is what I have tried...,
Java Code:
import java.util.Scanner;//Permite el uso de leer el teclado del usuario public class DeterminarValorDecimal//Nombra el documento { public static void main(String [] args)//Podemos ver la clase {
[Code].....
But what this does is I have to enter the single digits one by one. I want to be able to type the whole number. Is there a method that reads the length of the whole number and lets me classify each digit so I can do what I want to do?
This code is for a GUI Java program that is supposed to convert back and fourth between two numbering systems. For example, binary to decimal or decimal to binary. I have created methods for some of the conversions however, I could successfully develop a method to convert from hex to binary. If you plan to run it to see what happens to the current method that I made please know that in the GUI the north end from left to right is as follows.
The textfield is for user entry of any type of data. The first combobox is for the user specifying to the program what type of data he or she entered. The second combobox is for the user to choose what he wants that data converted to. The button is to convert it. The south side has a textarea that gives out the results. Please note that only some of the conversions work so far. There are comments in the code to label which methods do what converisons. Need to find a method that will convert from hex to binary, what is wrong with the current method.
Write a program that will provide temperature conversions between degrees Fahrenheit and degrees Celsius. Provide a method that will take an argument representing a temperature in Fahrenheit degrees and return the equivalent temperature in degrees Celsius. Also provide a method that will take an argument representing a temperature in degrees Celsius and return the equivalent temperature in degrees Fahrenheit. Conversion formulas are as follows: F = 9./5. * C + 32, C = 5./9. * ( F - 32 ), where F = Fahrenheit temperature and C = Celsius temperature. You must prompt for input using the Input class methods that are provided as a download for this unit.
I have two questions, 1st is why won't I get an output from my program when I run it? 2nd is how do I prompt for input using the Input class methods downloaded? The downloaded files are in .class form, and won't show any output when I run them.My code is:
import java.util.*; public class temp { public static void main ( String [] args ) { Scanner in = new Scanner(System.in);
public class Search { public static final int NOT_FOUND = -1; public static int binarySearch( int [ ] a, int x ) { int low = 0; int high = a.length - 1; int mid; while ( low <= high )
[Code] ....
I keep getting illegal start of expression at ={-3,10,5,24,45.3,10.5}
It says I have 12 errors and I have tried so many things to fix it and I just don't know what to change to make it work.
A GUI program that allows user to enter their name and the program will convert it in number using array.
For example if i input "EUNISE" the output should be 521149195
Because the letter equivalent of
a = 1 b = 2 c = 3 d = 4 e = 5 f = 6 g = 7 h = 8 i = 9 j = 10 k = 11 l = 12 m = 13 n= 14 o = 15 p = 16 q = 17 r= 18 s = 19 t = 20 u = 21 v = 22 w = 23 x = 24 y = 25 z = 26
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).