Number System Converter

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


ADVERTISEMENT

Number Of Paths Coordinate System

Oct 18, 2014

I've been pondering about this algorithm for about a week but I'm still not able to write a "fast" working method/algorithm to solve the Number-of-paths-exercise we were given in my class />

So here's the task:
Write an efficient java program "Paths" which solves the following task:

- Read input n ∈ N and give output a(n) which is the number of paths from (0,0) to (n,0)
it is not allowed to go over the diagonal (m,m) and also not below the x-axis (m,0)

Here are the allowed steps:
u = (1,1), U = (1,4), d = (1,−1), D = (1,−4) and H = (1,0)
steps are performed in a two-dimensional-coordinate-system!

View Replies View Related

How To Make The Program Understand 10 Number System

Oct 24, 2014

I want to create a program where i can output a number. ex. 3452 And the program will output 3000: three thousand 5: five 53: fifty-three

How can i make the program understand the 10-number system?

View Replies View Related

Averaging Grades Program - System Crashes On Negative Number Input

Sep 30, 2014

I do now have the problem where i have to insert the numbers 1 to 100 individually in order to allow the program to accept a grade as high as 100%.

Also as soon as i type in a negative number the system crashes and shows me a error as attached.

/*
Averaging grades
To use the Java Swing interface to calculate the average of up to 50 grades.Average is calculated once -1 is entered as a value. The grades are then sorted from lowest to highest and displayed in a content pane which also displays the average.
*/

import java.awt.*;
import java.awt.event.*;
import javax.swing .*;
import javax.swing.text.*;
public class Averages extends JFrame {
//construct components
JLabel sortPrompt = new JLabel("Sort By:");

[Code] ....

View Replies View Related

GUI Temperature Converter

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

Degrees To Fahrenheit Converter

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

GUI Converter Button - Fahrenheit To Celsius

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

Fahrenheit To Celsius Converter - Output Box

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

GUI Java Program - Hex To Binary Converter

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

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 View Related

Roman To Arabic Numbers Converter

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

Roman To Arabic Converter Says Everything Equals 1

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

Arabic To Roman Numeral Converter

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

Hexadecimal Java Base Converter

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

Odd Results From Octal-decimal Converter

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

JavaFX 2.0 :: String Converter Interface?

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

String To Unicode Converter Program In Java

Mar 2, 2014

I need a program to convert any string of any language to unicode using java....

View Replies View Related

Output Error About Converter (Miles / Kilometer)

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

Number Guessing Program - Computer Guesses A Number That User Is Thinking Of Within Certain Range

Mar 28, 2015

I have a beginning Java Program I have been working on that creates a number guessing program where the computer guesses a number that the user is thinking of within a certain range. I so far have the program below, but need getting rid of a few kinks/ adding features.

-First, I need to set it up so that the user will be prompted and give a range. It should run and produce something like this:

Welcome to this first-ever mind-guessing program!

Please pick a range (higher than 1 and no larger than 50): 32

You will choose a number between 1 and 32... and I will try to guess it.

With each of my guess, you will tell me whether I am too high (h or H), too low (l or L), match (m or M), or you want to quit (q or Q). My objective is to find the number using as few guesses as possible.

-Second, the game is supposed to give up and restart after failing the five, guesses, but for some reason, after it fails the fifth time, it prompts a fifth guess once again instead, then restarts after- I need to prevent this, so that it should look something like this:

My fourth guess is 17: h
My guess is too high?

My fifth guess is 16: h
*** I am unlucky this round. I give up.

Let's play!

My first guess is 10:
etc..

import java.util.*;
import java.lang.Math;
public class numguessprac1 {
// Declaring variables
public static String input;
public static int quit;
public static int guess;
public static int wins;

[Code] ....

View Replies View Related

User Enter 5 Digit Number And In Return List Each Number On Their Respective Lines

Sep 16, 2014

So I am currently writing my first assignment and have run into problems with my coding. The task was to have someone enter a 5 digit number and in return, I list each number on their respective lines. We also must create an error if a number other than 5 digits was entered. My problem is that when they enter a 1 or 2,3,4,6,7,8 digit number.. the error message occurs along with the rest of the messages (listing the numbers, etc). I want the program to end (or even re-ask to enter the numbers) if they incorrectly enter the data.

View Replies View Related

Program That Takes A User Inputted Number And Converts It To A Binary Number

May 5, 2014

trying to write a program that takes a user inputted number and converts it to a binary number.

Here's what I have:

package com.java2novice.algos;
import java.util.Scanner;
public class Converter {
static Scanner console = new Scanner(System.in);
public void printBinaryFormat(int number){
int binary = console.nextInt();

[Code]...

Bugs on:

Line 13
Line 17
Line 23

View Replies View Related

Calculate Total Length Of N Number Of Bamboo Trees In M Number Of Seasons

Feb 20, 2014

In a forest, there are some bamboo trees .The length of each tree get doubled during winter and increases by one unit in summer , write a Java program to calculate the total length of n number of bamboo trees in M number of seasons. The season always starts with winter.

import java.util.Scanner;
public class Tree {
public static void main(String args[]) {
int length;
int season;

[Code] ....

View Replies View Related

Compute Recursively Total Number Of Blocks In Triangle With Given Number Of Rows

Jul 8, 2014

We have triangle made of blocks. The topmost row has 1 block, the next row down has 2 blocks, the next row has 3 blocks, and so on. Compute recursively (no loops or multiplication) the total number of blocks in such a triangle with the given number of rows.

triangle(0) → 0

triangle(1) → 1

triangle(2) → 3

View Replies View Related

Creating Method That Prints The Square Root Of A Number Up To A Certain Number?

Feb 27, 2015

I am trying to create a method that prints the square root of a number up to a certain number. It needs to take a single int parameter for example "n" , and then print all of the (positive) even perfect squares less than n, each on a separate line. I want the method to be called something like this:

public void Squares(int n) {
}

I need the output to look something like this:

Example: if n = 40, your code should print

4
16
36

So I have been working for a few hours now and am really stuck.

This is what I have so far:

int count = 0;
int n = 4;
int max = n;
while(count < max) {
System.out.println(n);
n = n * n;
count++;

View Replies View Related

Program Is To Accept Number And Display New Number After Removing All Zeros

Dec 29, 2014

ex
Sample input:2340980
Sample Output:23498

this is the program i have tried but is dosent work

import java.util.*;
class zero
{
public static void main(String args[])
{

[Code]....

View Replies View Related

How To Create Simple Random Number Generator For Number Between 1 -10

May 18, 2015

I am working on a little nothing project, but I wanted to create a random number generator for a silly game where the user guesses the number.I have used google, but they are using LOG statements, what it does.

View Replies View Related







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