Translator Program That Will Convert English To Custom Binary
Aug 23, 2014
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();
public static void main( String [] args ) { int n = Input.getInt( "Enter 1 for Morse to English, 2 for English to Morse." ); switch ( n ) {
[Code] ....
When I compile my program, I get the error message: "illegal start of expression" at my toEnglish and toMorse methods, as well as " ';' expected " at the same place.
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); //
Multiple markers at this line - void is an invalid type for the variable loadDictionaryFromFile - Syntax error on token ")", ; expected - Syntax error on token "(", ; expected
Line 13 starts public void load....
Code:
import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.Scanner; public class PirateTranslator { public static void main(String[] args)
I'm doubted regarding the implementation of Collections.binarySearch() method on an ArrayList of objects of a custom class Movie.
Here is the movie class :
public class Movie implements Comparable<Movie> { String movieName; String rating; String director; String theme;
[Code] .....
The sort/binarySearch in searchByMovieName function is done with natural sorting (and Comparable Interface in Movie class). I mean no comparators involved here. And the comparator that I used for sorting/binarySearching on Movies Director attribute in searchByMovieDirector function is :
public class MovieDirectorComparator implements Comparator<Movie> { public int compare(Movie movie1, Movie movie2) { return movie1.getDirector().compareToIgnoreCase(movie2.getDirector()); } }
But I was not able to implement binarySearch ?? How to implement the binarySearch here. I have google to see only binarySearch working on Arrays or probably ArrayList of String only, but not on ArrayList of custom objects.
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 making a java program that translates English into Pirate. I need working with the Word Pair class. I'm not sure what needs to be passed to the default constructor. And how to do the method that will take the words and pair them. here is my code and the dictionary file
import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.Scanner; public class PirateTranslator { public static void main(String[] args)
I'm having some trouble with getting this program to read an input of morse code and then produce an output of English. When typing in morse code for the phrase 'the string', the output looks something like this:
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 have a custom library I made to make things easier for myself. I used it in a small program in NetBeans and it works fine. When I try to clean and build, it says it can't find the methods from my Library class. How do I get the library packaged into the jar?
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 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'm (failing at) writing a program that searches an array using binary search, but I can't get it to work.
My code so far is this:
Java Code:
package sorting;
import java.lang.*; import java.util.*; public class sorteh { public static void main(String [] args){ int[] array=new int [20]; //creates new array for (int x=0;x<array.length;x++){ //populates array array[x]=x*3+1;
[code]...
I copied what a website did for the sorting part, but if I have low=0 and high=19, wouldn't mid not be an int?
I wrote a java program for my gui number converter app, the main purpose of this program is to make sure that user enters only a binary number for conversion from binary to other number formats. the problem is my program keeps prompting me to enter correct binary number, no matter if i enter correct binary number, it will still keep prompting me to enter correct number. Here is the code
import java.util.*; public class test { Scanner key = new Scanner(System.in); String in; int b; public test()
i am new to programming skills it may be silly question for experience but for me it's new thing. actually i tried a lot but i am facing problem when i trying to take input through Scanner. if i will take input a sentence directly as a string it's working . but when i am trying with Scanner the first word is showing next are not showing
public class Demo2 { public static void main(String[] args) { String s1="hi how are you"; s1=s1.replace('a', 'A'); s1 =s1.replace('e', 'E'); s1 =s1.replace('i', 'I');
[Code]...
this is working properly.
but when i trying with Scanner i am facing problem.
public class Demo2 { public static void main(String[] args) { java.util.Scanner scn= new java.util.Scanner(System.in) String s1=scn.next(); s1=s1.replace('a', 'A');
I am trying to write a program converting Fahrenheit to Celsius using a for loop. I get it to run and Fahrenheit goes to a hundred. My issue is that the Celsius just says 100 down the column and is not converting. I have tried messing with it, and can not figure what is wrong with it.
import java.util.Scanner; public class Controlstatement { public static void main(String[] args) { double F = 1.0; double Celcius = 100; System.out.printf("%s%20s", "Farenheit", "Celcius" ); for (int Farenheit = 0; Farenheit <= 100; Farenheit++) { F = Celcius * (Farenheit - 32 * 5.0/9.0); System.out.printf("%4d%,20.2f", Farenheit, Celcius); } } }
I just started programming yesterday, and I have been making little programs to learn some algorithms and the syntax of java. I tried making a program that could convert metric units into the American system. Whenever I try to compile the code, it shows up as an "incompatible type" error. I know this is probably a very obvious answer to most of you, but I can't figure it out.
import java.util.Scanner; public class MetricToAmerican { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("fWhat measurement would you like to convert into US system? celsius, meter, or kilogram ");
Write a GUI program to convert all lowercase letters in a string to uppercase letters, and vice versa. For example, Alb34eRt will be converted to aLB34ErT.