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


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

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

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

Find Distance Between One Point To Another Using Miles And Feet?

Sep 19, 2014

Pretty much what im trying to accomplish, i need to write a program that figures out the distance between one point to another, using miles and feet..

Heres how it has to look: "The distance from my uncles house is ___ miles, or ____ feet."

I can get it to run if i add only whole miles..but when i try to add 8.5 miles, and compile, the program flips out..I know i need to use a double somewhere, but cant figure it out, here is my code..

import java.util.Scanner; //required for input
public class feetToMiles {
public static void main (String[] args){
//Create new scanner object called input
Scanner input = new Scanner (System.in); //allows for input

[Code] ....

View Replies View Related

User Input In Miles And It Is Supposed To Multiply With Feet

Sep 21, 2014

I have a program where the user enters in the miles and then it is supposed to get multiplied by feet but I keep getting this error.

GetUserInfo.java:12: error: bad operand types for binary operator '*'
int total = name * feet;
^
first type: String
second type: int

1 error

This is my code so far :

import java.util.Scanner;
public class GetUserInfo
{
public static void main(String[] args) {
String name;
int miles;

[Code] ....

View Replies View Related

Calculate Number Of Square Feet In A Tract Of Land With 3.5 Acres

Jan 27, 2014

1. Land Calculation

One acre of land is equivalent to 43,560 square feet. Write a program that calculates the number of square feet in a tract of land with 3.5 acres. Hint: Multiply the size of the tract of land (in acres) by the number of square feet in an acre to get the number of square feet in the tract.

a) You must have a variable called nrAcres where you will store the number of acres in the track.

b) Output must look as follows:

Size of land in acres: 3.5
Size of land in square feet: 152460

c) if the value of the variable nrAcres is changed the output should change accordingly. In other words: it would be wrong to have the following statement:

System.out.println("Size of land in square feet: 152460");

previous statement will print the correct output but will not change if you change the value of nrAcres.

View Replies View Related

Calculate Number Of Square Feet In A Tract Of Land With 3.5 Acres

Jan 27, 2014

Land Calculation

One acre of land is equivalent to 43,560 square feet. Write a program that calculates the number of square feet in a tract of land with 3.5 acres. Hint: Multiply the size of the tract of land (in acres) by the number of square feet in an acre to get the number of square feet in the tract.

a) You must have a variable called nrAcres where you will store the number of acres in the track.
b) Output must look as follows:

Size of land in acres: 3.5 Size of land in square feet: 152460

c) if the value of the variable nrAcres is changed the output should change accordingly. In other words: it would be wrong to have the following statement:

System.out.println("Size of land in square feet: 152460");

previous statement will print the correct output but will not change if you change the value of nrAcres.

this is what i got so far

public class Land
{
public static void main(String[] args){
double nrAcres = 3.5;
int feetInAcre = 43560;
double feetInTract = nrAcres * feetInAcre;
System.out.println("Size of land in acres: " + nrAcres + "
Size of land in square feet: " + feetInTract);
}
}

i tried to compile it but it says

error: class names, Land, are only accepted if annotation is explicitly requested 1 error

what is wrong with my code

View Replies View Related

Enterprise JavaBeans :: JPA With 3 Tables - Evaluate Query By Joining 2 Tables And Update Results In 3rd Table

Nov 8, 2013

I have 2 tables on 1 database

Table A, Table B

I need to evaluate a query by joining these 2 tables and then update the results in the 3rd table in another database. I need to use stateless session bean using JPA I believe. I need 3 Entities for each of the tables here.

View Replies View Related

Tables In Java

Mar 22, 2015

We started learning about tables and have a little program. The teacher gave us an excercise and doesn't works (not running), I receive too many errors. So any simple java program with tables with 20 numbers, that is giving random numbers?

View Replies View Related

Fetching Rows From 2 Tables Using HQL

Sep 29, 2014

Using HQL I am fetching the rows , now i need to iterate through the list and convert each row in the list to a "string" and append the string to a buffer.... How to do it

View Replies View Related

JSP :: How To Delete And Insert Data Into Two Different Tables

Jun 2, 2014

I am creating a portal using JSP and MySQL with eclipse IDE. I have a scenario where data is stored on draft table and is retrieved then stored on another table. I need the entry in the draft table to be deleted after the insertion. When I tried to run the code it redirects to success page but makes no impact on database(neither inserts not gets deleted).

<%@ page import="java.sql.*" %>
<%@ page import = "java.util.Date,java.text.SimpleDateFormat,java.text.ParseException"%>
<html>
<head>
<title>JSP Processing</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

[code]....

View Replies View Related

Formatting Tables For Console Output?

Apr 13, 2014

I am writing a class which formats console output as a table. It displays the type of an entry, the name of an entry, and the data for an entry. I am stuck on a required for loop which appends a tab character to a string, for formatting it as a table. It doesn't seem to be adding any of the tabs and I can't tell what I've done wrong. As far as I can tell the contents of the loop are never reached, and I can't make sense of it.

The ConsoleWriter class that contains the code that is in error...

Java Code:

package frontend;
public class ConsoleWriter {
private static String tabbedData(String data, int min) {
System.out.println(); //for debug
int tabcount = 0;
int len=8*min;

[code]....

View Replies View Related

How To Create Sports Tables Java Applet

Jun 1, 2014

I've been using a Java applet for sports tables.It has been very useful for me. However, the recent developments from the people at Oracle have made this program impossible to use. The point is that I need this program and I need it fast.I've been in touch with the person who once created this applet and he has no intentions at all to upgrade it or do anything to make it function. How to make the program works with their new updates.

View Replies View Related

Retrieve Data From Database By Joining Tables

Dec 23, 2014

I am trying to retrieve data from my database by joining my tables. So far i have managed to join my four tables in my database and retrieve all the information in that table. Now what i want to do is create a prepared statement in java that allows me to retreive certain data. Here is my joining query.

SELECT student.idNumber,student.names, student.surname,
course.description,
coursemarks.mark,
class.form,class.id
FROM `student`
LEFT JOIN `coursemarks` on student.idNumber = coursemarks.studentid
LEFT JOIN `course` on course.courseid = coursemarks.courseid
LEFT JOIN `class`on student.idNumber = class.studentID;

What I want is to select all the data depending on the class passed and the form passed, e.g a person might decide to select a certain form only or a certain form and class

View Replies View Related

Spell Checker Using Hash Tables Not Working

Feb 10, 2014

I am trying to use this program for reference but its not working ...

View Replies View Related

How To Make Print Employee Button To Print Info Of Other Class

Apr 12, 2014

Basically the class is supposed to have a static variable that keeps track of the number of companies (numberOfCompanies) that have been created and a static method that returns the value of this variable. I need to have a constructor and a method to addEmployee, a method to printCompany, and a toString method. The addEmployee method will check that there is only 1 salesperson, 2 designers, and 4 manufacturing persons at a time and will check that there are no more than 7 employees of the company.

The addEmployee method will return a String indicating what the error is (i.e. "There is already a sales person in this company") or a null if the employee was added. If attempting to name a third company, an error message will be shown. what i have so far but my print company mmethod returns null company class :in which i am obliged to use inputdialog because it says that it cannot return void when i use the showmeassage diaolog.

company class:

import java.util.ArrayList;
import javax.swing.JOptionPane;
public class Company {
private ArrayList<Employees> list ;
private static int numberOfCompanies;

[Code] ....

error message when print button is clicked:

Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: JOptionPane: parentComponent does not have a valid parent
at javax.swing.JOptionPane.createInternalFrame(Unknown Source)
at javax.swing.JOptionPane.showInternalOptionDialog(Unknown Source)
at javax.swing.JOptionPane.showInternalMessageDialog(Unknown Source)

[Code] ......

View Replies View Related

Two Threads - One Will Print Odd And Other Will Print Even Numbers In Sequence

Jul 25, 2014

I want to create two thread one thread will print odd number and another thread will print even number. but the number should be in a sequence like

1 2 3 4 5 6 7 8 9 10

View Replies View Related

How To Print First 5 Values

Nov 16, 2014

See the below:

public static void main() {
int i; // counter
  createDeck(); // this is a function call
  // Show the cards in the deck
System.out.println("The deck is as follows:");
for (i=0 ; i < CARDS_IN_DECK ; i++)

[code]....

It is now printing out the value of myDeck[5] but I need to print out first 5 values.

View Replies View Related

Unable To Print Sum Of First Row?

Dec 11, 2014

Java Code:

public class Lab12 {
public static int SumRow(int [][] a){
int row, column, sum=0;
for (row=0;row<2;row++ ) {
sum=0;
for (column=0;column<2;column++) {
sum=sum+a[row][column];

[Code]...

my output is

The sum of row 1 is: 3
The sum of coloumn 0 is: 5
The sum of coloumn 1 is: 5
The max of row 0 is: 4
The max of row 1 is: 2

it is supposed to print the sum of row o first ?

View Replies View Related

How To Print Before And After A Word

Nov 28, 2014

i have completed a code in java so that it can read spaces in a line but when i run it if i put Line 1 test test for example it will print : [ 3] spaces in Line1 test test what i want to print is [ 3] spaces in "Line1 test test" so the diferences is at " Is there any possible thing that i can do?

class Main
{
public static void main( String args[] )
{
System.out.print( "#Enter text : " );
String text = BIO.getString();
while ( ! text.equals( "END" ) )
{

[Code]...

View Replies View Related

Can't Print Number

Oct 14, 2014

I can't print the number that is supposed to come out

public class Skateboard {
private int wheels = 4;
private int trucks = 2;
private int bearings = 8;
private int gripTape = 1;
 
[code]....

How come sb1.assembly() doesn't return the values? :/

View Replies View Related

JSP :: How To Print Alphabets

Feb 24, 2014

I am trying to print alphabets from A to F using <c:forEach>

<c:set var="ctr" value="${optListSize}"></c:set> //optListSize is the size of an arraylist
<c:forEach begin="65" end="${ctr}" varStatus="loop" step="1">
<c:out value="<%=String.fromCharCode(64+${ctr})%>"></c:out>
</c:forEach>

I tried the above code but it gives an error. How to go about printing A, B, C, D... incrementally

View Replies View Related

How To Print Out First 6 Character Of Last Name

Feb 20, 2015

How to i print out the first 6 character of a last name even if the last name is and X like Malcolm X or Sung Li. X and Li being the last names

View Replies View Related

How To Print Big Integer Using For Loop

Mar 6, 2015

I amtrying to iterate a value of L,R both are range of BigInteger but its not working

BigInteger L=in.nextBigInteger();
BigInteger R=in.nextBigInteger();
for (BigInteger bi =L;
bi<=bi.compareTo(R);
bi = bi.add(BigInteger.ONE)) {

//Task to do with Numbers
}

I am trying to iterate a for loop in range of L and R but its not working

View Replies View Related

Print A Diamond Using For-loop?

Mar 26, 2014

I am currently trying to print a Diamond using for-loops but I seem to be confusing my self / over-complicating it.

This is what I have so far [URL]). When I run the code I get [URL].

I want to duplicate it on to the other side but I can't seem to be able to figure out a working for-loop to print it out.

Also, is there a faster/efficient method of doing something like this?

View Replies View Related







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