Semantic Error In Hexadecimal Converter
Jun 29, 2014
I'm sure the solution is simple, but I cannot find it.
/*reads a hexadecimal number input by the user and gives the corresponding base-10 value
*/
public class HexConverter
{
static int i; //used to keep place in the hexadecimal sequence given by user
public static void main(String[] args) {
//declaration of variables
String hexgiven; //the hexadecimal sequence given by user
[Code] .....
View Replies
ADVERTISEMENT
Apr 28, 2015
I am writing a program that converts any base 10 number to bases 2-16. I have the code for everything up through hexadecimal conversion, for that requires the use of letters. I understand an array list may be of use however I do not understand how to use that in this code. Below is what I have so far
import java.util.*;
import java.io.*;
public class convertBase
{
public static void main(String[] args)
{
int base;
int number;
String newNum;
[code].....
I commented out the hexadecimal portions.How would I go about coding for letters?
View Replies
View Related
Oct 5, 2014
why the output is not giving the proper result? Is this a semantic error?
public class Programming1Practice {
/* testing out instantiation and object oriented programming */
public static class staticValues {
[Code]....
View Replies
View Related
Nov 28, 2014
I'm doing to create miles/kilometers converter. If I put the mile, converting to kilometer is right. However, if I put the kilometer, converting to mile comes out wrong value. Which part is wrong?
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
[Code] .....
View Replies
View Related
Jul 15, 2014
how to write the toString to convert this output :
List:
side: 14 color: java.awt.Color[r=0,g=0,b=255]
side: 18 color: java.awt.Color[r=255,g=0,b=0]
side: 12 color: java.awt.Color[r=255,g=255,b=0]
side: 18 color: java.awt.Color[r=255,g=0,b=0]
side: 16 color: java.awt.Color[r=0,g=255,b=0]
side: 10 color: java.awt.Color[r=255,g=200,b=0]
side: 10 color: java.awt.Color[r=255,g=200,b=0]
to this output
side:14 color:#0000FF
side:18 color:#FF0000
side:12 color:#FFFF00
side:18 color:#FF0000
side:16 color:#00FF00
side:10 color:#FFC800
side:10 color:#FFC800
here is how i have it written now
public String toString()
{
return "side: " + side + " color: " + color + "";
}
View Replies
View Related
Jul 16, 2014
Java programming, I decided to write a code today that would convert decimal numbers to hexadecimal numbers. Unfortunately, it does not compile. The error message is "cannot find symbol - variable A", and might be the same error for the other variables B,C,D,E,F.
Here is my code:
public class dec2hex
{
public static void main (String [] args)
{int nbr = 99;
char a = A;
char b = B;
char c = C;
[Code] ....
View Replies
View Related
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
Mar 12, 2014
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.
View Replies
View Related
May 4, 2015
I am having calculation issues converting Fahrenheit to Celsius. The Celsius to Fahrenheit is working properly.
private void convertButtonActionPerformed(java.awt.event.ActionEvent evt) {
int tempFahr = (int)((Double.parseDouble(tempText.getText()))
* 1.8 + 32);// Calculate Fahrenheit to Celsuis:
fahrenheitLabel.setText(tempFahr + "Fehrenheit");
}
[code]...
View Replies
View Related
Mar 2, 2014
I am trying to teach myself a bit of java and came across the following line of code in the degrees to Fahrenheit converter tutorial:
int tempFahr = (int)((Double.parseDouble(tempTextField.getText()) )
* 1.8 + 32);
I know what the code does in that it is getting the value that the user has input in text field tempTextField and is applying the mathematical calculation to convert to Fahrenheit and assigning the result to the variable tempFahr.
I am guessing any value input into a text box is considered a string?I am guessing that Double.parseDouble takes in a string and converts it to a double.I am assuming that by simply putting (int) in front of
(Double.parseDouble(tempTextField.getText())) * 1.8 + 32)
that it calculates the value and converts it to an int?The tutorial says this example is not localizable because the parseDouble method is not localizable - what does it mean by localizable?
View Replies
View Related
Feb 15, 2013
This program requires knowledge of manipulation of Java String objects and methods. It also requires knowledge of Number System Conversions.
// Lab16MATH05st.java
// The Number System Converter
// This is the student, starting version of the Lab16MATH05 assignment.
import java.util.Scanner;
public class Lab16MATH05st
{
public static void main (String args[])
{
System.out.println("Lab16MATH05 - Number Conversion Program
[code]....
90-Point Version Specifics: The 90-point version requires that you write both the fromHexToBin and fromBinToDec methods.
90-Point Version Output
95-Point Version Specifics {The 95-point version requires everything from the 90-point version and adds the fromBinToHex method. For this version, you may assume that the binary number will have a multiple of 4 bits.
95-Point Version Output
100-Point Version Specifics: The 100-point version requires the same methods as the 95-point version; however, the fromBinToHex method needs to be improved so it can convert regardless of the number of bits.
100-Point Version Output
105-Point Version Specifics: The 105-point version requires everything from the 100-point version and adds the fromDecToAny method. For this version, the method needs to be able to convert from decimal to any base between 2 and 10. Base 16 is not required for this version.
105-Point Version Output
110-Point Version Specifics: The 110-point version requires the same methods as the 105-point version; however, the fromDecToAny method needs to be improved so it can also convert to base-16.
View Replies
View Related
Nov 13, 2014
I am new to java and I am trying to learn a little about GUI. I found this problem of creating a converter for temp from farenheit to celcius. I have everything working, except for when I hit the converter button... it does not convert.
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
[Code] .....
View Replies
View Related
Sep 23, 2014
The assignment reads: Develop a Java program (F2C.java) for converting a temperature from the Fahrenheit to the Celsius scale. The program will read the temperature graphically using an input dialog box
(JOptionPane.showInputDialog) and will show also the result graphically on a message dialog box (JOptionPane.showMessageDialog).
I can get my input box to show, but I am unable to get to the output box
What I have came up with:
import javax.swing.JOptionPane;
public class F2C {
public static void main(String[] args) {
// Enter Farenheit
String Fahrenheit = JOptionPane.showInputDialog(
[Code] .....
View Replies
View Related
Mar 11, 2014
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.
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
[Code] .....
View Replies
View Related
Oct 5, 2014
I'm trying to do a program to convert roman numbers to arabic numbers. My problem is that I don't have the right to use Methods and Arrays. Only loops and if/else.
View Replies
View Related
Mar 25, 2015
Im working on a roman numeral to arabic converter and all I had to do was fill out the conversion method romanToDecimal. But for some reason no matter what number I enter It always says my number is equal to one.
//Quiz 1 EC
import java.util.*;
class Roman {
private String romanNum;
private int decimalNum;
public Roman(){
romanNum = "I";
decimalNum = 1;
[code]....
View Replies
View Related
Sep 12, 2014
I got part of this converter built and running fine but now it's getting weird. Specifically I am getting to the part where I have to count above ten which means things like attaching Vs to Is and Xs and suchlike.
I know I have to use an .append someplace, I am just not certain how to go about it. I've been playing with it some, but this is honestly the biggest thing I've built so far that actually *ran* so I'm afraid to poke too many holes in it... where do I start? It's not like I can invent another return string and concatenate them. R is what I've got.
package hello;
public class RomansatHomans {
public static void main(String[] args) {
// input fed on this line loops through toRo and comes back as a String
// R
String R = toRo(23);
// int D = froRo("x");
[Code] ......
View Replies
View Related
Mar 13, 2015
I wrote this small program to take an octal number from the user and convert it to decimal form.
import java.util.Scanner;
public class Decimal
{
public static void main (String args []) //gets octal number from user, later prints conversion
{
int octal;
[Code] .....
Some conversions work. For example, 77 will be correctly converted to 63, and 77777777 will be converted to 16777215. However, some conversions do not work. An example of this is 775002 gets converted to 74898.
View Replies
View Related
Feb 4, 2015
Is there a good reason for which StringConverter is an empty abstract class instead of being an interface ?It could spare the overhead of an embedded object reference ...
View Replies
View Related
Mar 2, 2014
I need a program to convert any string of any language to unicode using java....
View Replies
View Related
May 22, 2014
For my jsp file, the code editor shows no error, but the projects window shows an error. I built my project again, cleaned the project, restart eclipse twice and summoned cthulhu. But my project still shows an error. How do I find the cause.
Eclipse project -
JSP file -
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="mine" uri="DiceFunctions"%>
[Code] ....
View Replies
View Related
Apr 5, 2014
I have written some error checking code
File name ErrorPage.jsp
<%@ page language="java" isErrorPage="true" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Error</title>
</head>
[code]...
I have put error.jsp and badpage.jsp file in public access folder that is web content in eclipsewhen I am running the code I am status code of 500 and not the errorpage.jsp message .
View Replies
View Related
Mar 24, 2015
I need to compile a JAVA code to call a web service. The web service provider gave me this sample code, but compiling with javac i have one error for each row of code.
Code attached!code.txt
View Replies
View Related
Oct 10, 2014
import java.util.Scanner;
public class Pract3CQ2 {
public static void main(String [] args) {
Scanner keyboardIn = new Scanner (System.in);
//Declare variables
int a=20, b=10, diff;
[Code] ......
View Replies
View Related
Dec 31, 2014
here is code :
public final static void main(String[] args){
double d = 10.0 / -0;
if(d == Double.POSITIVE_INFINITY)
System.out.println("Positive infinity");
else
System.out.println("Negative infinity");
}
now ideally this might throw Arithmetic Exception.. but it prints positive infinity ,.. why.. ??
View Replies
View Related
Oct 23, 2014
I am getting a NullPointerException Error and I cannot seem to figure out what is causing it. I am reading in a grades1.dat text file and putting the values into a 2D array. The error is occuring in my addGrade method, but I am not sure what the error is. Here are the values for my grades1.dat that I am running in through Run Arguments in JGRASP.
Student1
5
a Activities 0.05
q Quizzes 0.10
p Projects 0.25
e Exams 0.30
f Final 0.30
a100 a95 a100 a100 a100
q90 q80 q100 q80 q80 r90
p100 p95 p100 p85 p100
e77.5 e88
f92
Here are the errors that I am getting.
Exception in thread "main" java.lang.NullPointerException
at GradeBook.addGrade(GradeBook.java:114)
at GradeBookApp.main(GradeBookApp.java:55)
import java.util.Arrays;
/**
* Stores students name, a char array of category codes, a String array of categories, a double array of category weights, and a two dimensional double array of grades where each row contains all the grades in a particular category.
[code]....
View Replies
View Related