Stuck In Converting Meters In Millimeters

Feb 18, 2014

here's my code:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class Milimetri extends JFrame {
private JPanel p1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
private JPanel p2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
private JPanel p3 = new JPanel(new FlowLayout(FlowLayout.LEFT));

[code]...

When i write a value in meters ..and press the button b1 to show me a value in milimeters..

View Replies


ADVERTISEMENT

Converting Meters To Feet - How To Print Decimals

Oct 1, 2014

I am making a small program that converts meters to feet. I want my answer to be printed with 2 decimals, but I am struggle. This is my current code, any takes on what needs to be changed and why?

import java.util.Scanner;
import java.text.DecimalFormat;
public class Chapter2PE3 {
public static void main (String[]args){
Scanner input = new Scanner (System.in);

[Code] ....

View Replies View Related

Print Out Two Different Tables One For Feet To Meters And Other From Meters To Feet

Feb 19, 2015

I can get this program to run and compile, however, upon printing, I have the lastnumber from each table printing on the next line under their respective tables.

public class Lab6 {
public static void main(String[] args) {
double foot = 0;
double meter = 0;
System.out.println(" Feet Meters");
System.out.println(footToMeter(foot));

[Code]...

and what it prints is this:

Feet Meters
1.0 0.31
2.0 0.61
3.0 0.92
4.0 1.22
5.0 1.53
6.0 1.83
7.0 2.14
8.0 2.44
9.0 2.75
10.0 3.05
3.05

Meters Feet
20.0 65.57
25.0 81.97
30.0 98.36
35.0 114.75
40.0 131.15
45.0 147.54
50.0 163.93
55.0 180.33
60.0 196.72
65.0 213.11
213.11475409836066

how do i get rid of the last 3.05 and 213.114754...?

View Replies View Related

Feet To Meters And Display Result

Dec 3, 2014

I have to do feet to meters code. here is the question. Write a Java program that reads a number in feet, converts the number to meters and displays the result. One foot is 0.305 meters.

here is my code :

import java.io.*;
class FeetToMeters
{
public static void main (String[] args) throws IOException
{
InputStreamReader inStream = new InputStreamReader (System.in);
BufferedReader stdin = new BufferedReader (inStream);

[Code] ....

I have seen alot of people use the scanner tool for the start of it but we never learned it as it is an online course but we may end up learning it farther on in our java programming. we have just started with the input and output stuff.

View Replies View Related

Got Stuck With ClassCastException

May 18, 2014

I'm doing a project in netbeans. I have to make a on-line bank with all the GUI. In the middle i got stuck with the classcastexception..

public class Banca {
public static void main(String[] args) throws IOException, ClassNotFoundException {
// dati dei clienti
Anagrafica c = new Anagrafica();

[code]...

And here's the class of the activities of an account.. I'm not posting my classes Conto( Bankaccount) & Movimento (Activity) because those two already do what they should..

View Replies View Related

While Loop Stuck

Mar 16, 2014

I'm trying to do the following and my code is putting me in a loop and not allowing me to input a valid entry after using an invalid #.I ask the user for input which contains a loop if the user doesnt use the correct information, however the loop doesnt allow the user to input if the entry fails the which statement

import javax.swing.JOptionPane; // Needed for JOptionPane class
public class LoanQualifier
{
public static void main(String[] args)
{
double salary; // Annual salary
double yearsOnJob; // Years at current job
String input; // To hold string input

// Get the user's annual salary.
input = JOptionPane.showInputDialog("Enter your " +

[code]....

View Replies View Related

For Loop - Integers Stuck At 0

Oct 6, 2014

I have this code running correctly in Eclipse all except that it seems no matter where I declare, highest, lowest, average they always seem to stay at "0". I have a feeling the location of the Initialization is not the error since I have tried moving it to inside differ loops.

Stipulations on writing this code are:

Note: You do not need to use array to save each input score for this lab. A Single loop to read in each grade, compare with the current highest grade, lowest grade, and calculate the running sum at the same time.

import java.util.Scanner;

/*Write a program that prompts the user to enter the total number of students first.
*Then ask the user to input each student’s grade and use loop statements to read in each grade.
*Check input grade to make sure 0<=grade<=100, if the user input any other number, print out warning message and ask the user to input a new grade. Display the highest score, the lowest score and the average.
*/

public class LoopStatements {
// Main Method
public static void main(String[] args) {
// Initialize
int grade = 0; // grade value

[Code] ....

View Replies View Related

Stuck On Constructor With Parameters

Mar 19, 2014

How to use a constructor with parameters where the user inputs the information? I'm doing a problem where I create a Delivery class that accepts arguments for the year, delivery number within the year, distance code (1 for short distance, 2 for long), and weight of package. The constructor is supposed to also determine the eight digit delivery number (combining the year and delivery number, like 20140054 for this year, package #54).

I know I'm not close to being done but I'm struck on the application with the constructor parameters. If I'm asking the user to input the information, does that mean I have to create a no argument constructor so it will compile? Right now it won't compile because it's asking for the parameters but I can't put them.

This is the class:

public class Delivery {
int year;
int delNum;
double weight;
int code;

[Code] .....

And the error is:

CreateDelivery.java:22: error: constructor Delivery in class Delivery cannot be applied to given types;
Delivery firstDelivery = new Delivery();
^
required: int,int,int,double
found: no arguments
reason: actual and formal argument lists differ in length
1 error

View Replies View Related

JRadio Buttons Stuck On

Sep 26, 2014

I'm writing a temperature converter for class, and I'm done but one piece that I can't wrap my head around.My input scale radiobuttons work fine, but the output scale radiobuttons don't deselect automatically. They're two different button groups and I wrote them identical save for the variable names.

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

[code]....

View Replies View Related

Stuck On Two Dimensional Arrays

Apr 13, 2014

I am having trouble grasping 2 dimensional arrays .I have a certain problem:

String[][] words = {
{"Red", "Blue", "Green"},
{"Orange", "Purple". "Yellow"}

[code]....

I ran the code and got OrangePurpleYellowRedBlueGreen.

View Replies View Related

Stuck With A Logical Error

Jan 23, 2015

import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JTextField;

[code]....

Total IS those numbers. But question[10] will not cooperate with me and it's getting a bit aggravating as I can't find a logical reason for it to be doing that.how to perhaps lock the value of total and sTotal after 10 button clicks from any?

View Replies View Related

Stuck Sorting Arrays

Jul 1, 2014

Write a method called isSorted that accepts an array of real numbers as a parameter and returns true if the list is in sorted (nondecreasing) order and false otherwise. For example, if arrays named list1 and list2 store {16.1, 12.3,22.2, 14.4} and {1.5, 4.3, 7.0, 19.5, 25.1, 46.2} respectively, the calls is Sorted(list1) and isSorted(list2)should return false and true respectively. Assume the array has at least one element. A one-element array is considered
to be sorted. public class thirfd {

public static void main(String[] args) {
double[] arr1 = {16.1, 12.3,22.2, 14.4};
double[] arr2 = {1.5, 0.3, 7.0, 19.5, 25.1, 46.2};
isSorted(arr2);
System.out.println(isSorted(arr2));

[code]...

View Replies View Related

Stuck On Pyramid Program

Feb 13, 2014

I have spent some time thinking about the program, and realize I need two loops-- 1 that keeps track of bricks in a row and 1 that keeps track of the number of rows as the Pyramid rises in height. The Pyramid is supposed to be centered on the bottom of the screen. Three CONSTANTS have been required:

BRICK_WIDTH=30, BRICK_HEIGHT=12, BRICKS_IN_BASE=14.

I tried breaking the scope of things down by trying step-wise refinement. But, I got bogged down. When I tried a method where both loops were included, I got limited success. For some reason, my equation to center along the x axis seems to be doubling the number of bricks. But, the correct number of total rows of bricks was a success. Also, the Pyramid was centered on the bottom of the screen. Another frustrating failure was that the number of bricks would not decrease as the new layers were created. My thought process was instead of using a loop that counts up (i++) I would use a loop that counts down (j--) which I thought would reduce the number of brick in each row as the "y" coordinate was reduced by each count of the BRICK_HEIGHT.

This is the code that "works". Whenever I add the (j--) the results are NOT what I expect.

/*
* File: Pyramid.java
* Name:
* Section Leader:
* ------------------
* This file is the starter file for the Pyramid problem.
* It includes definitions of the constants that match the sample run in the assignment,
* but you should make sure that changing these values causes the generated display to change accordingly.
*
[code].....

View Replies View Related

Swing/AWT/SWT :: Stuck With A Custom TableModel?

Feb 2, 2015

I am trying to make a custom table for a DB and i am stuck.

I want only the first column to have a checkbox and others not.

Is there a better way to insert the values instead using the getValueAt ?

@Override
public Object getValueAt(int row, int col)
{
if (col == 0)

[Code].....

View Replies View Related

CompilerThread0 And CompilerThread1 Stuck - Cpu 100% All Time

Nov 4, 2013

my application (java 6 RedHat 5.3 x64 ) using clean content jar for extracting data from email messages with attachments (doc, xls, ptt ...etc) After update from CleanContent-2009.1.1.jar to CleanContent-2011.1.1.jar (and any newer version) CompilerThreads will stuck in some cases (pretty often) In that case CPU usage is 100% all time, even when all activities on application are finished.

I was able to isolate several messages and every time when I used CleanContent-2009.1.1.jar it works ok but always stuck with CleanContent-2011.1.1.jar or newer versions!

View Replies View Related

Stuck On Average Word Length

Aug 1, 2014

The goal of this code was to create a program using main method java to analysis a piece text which has been entered from a user.

They do this by entering the text into a scanner which is then analysed by the program. The analysis is to produce word frequency, for example " This is a test" produces this results:

This is a test

1 letter words: 1
2 letter words: 1
3 letter words: 0
4 letter words: 2
5 letter words: 0

The bit that I'm stuck on is producing a mean/average, My mind telling to divide

counts.length
by
str.length

But I'm not the Best at java and I've tried to implement this but all I get are errors.

Code:

import java.util.Scanner;
public class While_Loop {
public static void main (String[] args) {
while(true){

[Code] .....

View Replies View Related

Stuck On Adding Entries Method

Apr 13, 2014

I think I'm about 90% complete with this program but I'm stuck on my adding entries method. It gives me a runtime error which says:

Enter the name:
Bill
Exception in thread "main" java.lang.NullPointerException
at Phonebook.addEntry(Phonebook.java:70)
at Phonebook.main(Phonebook.java:49)

Here is my code:
/*
* This program asks the user for input for a name, phone number and notes up
* to 200 entries. It stores every contact in a file. Type 'h' for help while
* running this program.
*/
import java.util.Scanner;
import java.io.*;

[code]....

View Replies View Related

Stuck On IsBorrowed Method Implementation

Jul 19, 2014

Basically I have a class called Book. Its supposed to have a few simple methods that set the title of the book, mark it as returned or borrowed. So specifically my problem lies in the implementation of the method that decides if the book isBorrowed. I was thinking i'd use a simple if/else statement but the way i've been trying hasn't been successful. This is what i've tried so far.

public class Book {
String title;
boolean borrowed;
boolean returned;
boolean isBorrowed;
// Creates a new Book
public Book(String bookTitle) {

[Code] .....

View Replies View Related

Stuck In A Loop - Max Value Gets Reset To The Next Value In File

Mar 14, 2014

The problem i believe is that I have the max value set to the first value given out, but every time the loop repeats the Max value gets reset to the next value in the file.

Essentially the program is supposed to read a list of credit card transactions and tell the user which transaction is the highest.

Here's the list of the sample file, note that the number of transactions could change that's why i haven't tried simply passing the values to method.

Bicycle 562.90
Groceries 138.43
Hotel 612.00

import java.io.File;
import java.io.IOException;
import java.util.Scanner;
public class CreditCards {
public static void main(String[] args) throws IOException {
String fileName = "C:/Users/David/Desktop/CreditCard.txt";
File inputFile = new File(fileName);

[Code] ....

View Replies View Related

Stuck At Checking Winner And Valid Move On Tic Tac Toe

Oct 3, 2014

public class TicTacToeGame {
public static void main(String[] args) {
char [][] board = new char [3][3];
displayboard(board);
int count = 0;
boolean loop = true;

[Code] ....

I also try with check if the move is vaild but no luck with that.

View Replies View Related

JSF :: Click Link Tooltip Box Gets Stuck On Next Page

Jan 31, 2014

I have a tooltip implemented on a main page, but when you click the link tooltip box gets stuck on next page

<h:outputText value="#{it.get(newItem.strCampoNombre)}" rendered="#{newItem.strCampoTipo == '1' or newItem.strCampoTipo == '5' or newItem.strCampoTipo == '4' or newItem.strCampoTipo == '9' or newItem.strCampoTipo == '10' or newItem.strCampoTipo == '11'}" />
<h:outputText value="#{it.get((newItem.strCampoToolTip))}" rendered="#{newItem.strCampoTipo == '8'}" />
<rich:tooltip styleClass="tooltip" layout="block" rendered="#{newItem.strCampoTipo == '8'}" showDelay="500" onhide="false" hideEvent="mouseleave">
<span class="wrap"> <h:outputText value="#{it.get(newItem.strCampoNombre)}" /> </span>
</rich:tooltip>

problem.png

I tried to change the tooltip parameter but didnt find the solution.

View Replies View Related

Threads Stuck On Closing Brace Of While Loop

Apr 14, 2014

While analyzing the thread dumps for a performance issue in our java ee web application, I see many thread dumps stuck on a closing brace of a while loop. Here is the code block of a third party library bitronix (version 1.3.3 SNAPSHOT)
 
public XAResourceHolderState findXAResourceHolderState(XAResource xaResource) throws BitronixSystemException {
        Iterator it = resources.iterator();
        while (it.hasNext()) {
            XAResourceHolderState xaResourceHolderState = (XAResourceHolderState) it.next();
            if (xaResourceHolderState.getXAResource() == xaResource)
                return xaResourceHolderState;
        }      
        return null;
    }

The thread dumps indicate that many threads are stuck in RUNNABLE state on line number 07. What could be the possible reasons on why a thread could get stuck on a closing brace of a while loop? The iterator of the while loop is a custom implementation.

View Replies View Related

Stuck On Error - Could Not Find Or Load Main Class

Sep 2, 2014

I'm getting an error trying to run a welcome app from a book. I've looked at the FAQs and can't seem to solve the issue. I'm guessing my path and/or classpath are not right. Here's my path environment variable.

C:jdk1.8.0_20in;C:ProgramDataOracleJavajavapath;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS Client;%SystemRoot%system32;%SystemRoot%;%SystemRoot%System32Wbem;%SYSTEMROOT%System32WindowsPowerSh

[Code] ....

Here's my output.

09/01/2014 10:23 PM 634 Welcome.class
09/01/2014 10:21 PM 422 Welcome.java
14 File(s) 126,243,703 bytes
9 Dir(s) 53,942,079,488 bytes free

[Code] .....

It looks like the version command gives me what it should, so it appears I've got java setup right, but I"m stuck on the error I'm getting :

C:jdk1.8.0_20>javac -version
javac 1.8.0_20
C:jdk1.8.0_20>

View Replies View Related

Stuck On Porting Small Segment Of JavaScript To Java

Mar 3, 2014

I'm fairly good at Java, but somewhat at a loss when the some of the JavaScript below is mentioned. I've attempted to port the below code, but I'm finding it somewhat difficult.

Parts of JavaScript I'm stuck at porting:

1. I'm stuck on the return statement on the 3rd line.

2. Similarly the lines utilizing "charCodeAt", as I keep getting error "Cannot invoke charCodeAt(int) on the primitive type char"

3. Also on the second to last line, I keep getting the error "Cannot invoke padLZ(int) on the primitive type int".

Link to original javascript

Convert between Latitude/Longitude & OS National Grid Reference points

Original JavaScript

Java Code:

OsGridRef.prototype.toString = function(digits) {
digits = (typeof digits == 'undefined') ? 10 : digits;
e = this.easting, n = this.northing;
if (e==NaN || n==NaN) return '??';
// get the 100km-grid indices
var e100k = Math.floor(e/100000), n100k = Math.floor(n/100000);

[Code] ....

View Replies View Related

Print Route Method / Stuck In A Loop Of Printing Same Two Nodes

Nov 13, 2014

My issue is that when I run my search, it does find a goal. However, when I try and print the route using my print route method, it just gets stuck in a loop of printing the same two nodes. What is wrong with My A* implementation?

package search;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
 
[code]....

View Replies View Related

Java Socket - Client-server Communication Stuck With Multi-threading

Feb 6, 2015

Firstly, my code is just a demo of my multiplayer game (2 or more players can play simultaneously) to demonstrate my problem without any extra things. I have successfully implemented peer-to-peer (P2P) communication in my game. Later, I decided to add support for client-server communication (ie a central server which is also a player) in my game. It should be much easier than P2P. Now here is the problem:

Suppose, I have 1 server and some clients (may be 1 or more clients). They all should give the following output:

Starting...
A
B
C
E
F
...
...
Done!

They all give the above output without using multi-thread. But using multi-threading, it gives the above output only when there're 1 server and 1 client. I'm using 2 threads (1 for sending, 1 for receiving) for each Socket. That means, each client has only 2 threads for communication but the server has (2 * totalClients) threads.

I've attached my full test project. So, here I'm only showing my 2 thread classes.

ReceiveThread class:
class ReceiveThread extends Thread {
private ObjectInputStream receiveStream;
private BlockingQueue<Character> queue = new ArrayBlockingQueue<Character>(Common.totalClients);

[Code] ....

Since I've attached my full test project, I'm not showing the other 3 classes. They are ServerMain, ClientMain and Common. If I've 2 clients to be connected, then I get the following output:

Server: (Runs first)

Starting...
A
Client 1 (clientID is 1): (Runs after the server)

Starting...
A
B
B
Client 2 (clientID is 2): (Runs after Client 1)

Starting...
A

They are stuck at there, even no exception. Actually, the server and the clients are stuck at the line try { ch = queue.take(); } if more than 1 client are connected. It seems that all are trying to receive data. But without using the dedicated threads, they all work as expected even for more than 1 client. Why is this behaviour? How to solve it? Note that I have used the same SendThread and ReceiveThread classes by which I have succcessfully implemented P2P communication.

About my attached test project file:

It has 5 small .java files for the classes as stated above. It is currently faulty when using additional threads. You have to change clientID variable for each client (they are described inside). But it works as expected without additional threads. To test it without the additional threads:

Comment " TODO" linesUncomment the single lines just after " TODO" linesComment the additional thread construction lines (4 lines)

Currently, for a workaround, I'm not using the dedicated threads for sending and receiving data only for client-server communication in my multi-player game. But I'm still using these threads for P2P communication. I don't know why it is and how to solve it.This is the attached test project file as described above.

Attached File(s) : Test Project.zip (4.11K)

View Replies View Related







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