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
ADVERTISEMENT
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
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
Apr 21, 2014
I have html code that use form and the result displayed with display tag library the form forward to servlet page but when I use a javascript to change value of hidden after returning to html page the value of hidden input deos not change
<form name="form" method="get" action="Text" >
<input type="checkbox" dir="rtl" ID="CheckBox2" value="check" onclick="All(this,'all','_chk');">
</td>
<td> <input type="submit" name="delete" value="حذف"></td>
</tr><p>
<div align="center">
[code]....
View Replies
View Related
Apr 26, 2015
I am trying display the result set from the database.I am getting the following exception :
Caused by: javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied "items" in <forEach>
at org.apache.taglibs.standard.tag.common.core.ForEachSupport.toForEachIterator(ForEachSupport.java:286)
My Jsp code :
<%@ 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">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
[Code] ....
View Replies
View Related
Mar 29, 2014
I have a problem with my code,in fact I can't output the stream from console to my jTextarea,this is my code:
public class AudioFrame extends javax.swing.JFrame {
static double[] audioFile;
static String audioToDecode;
static String audioKey;
static String outputName;
static String outAudio;
static String name;
static int command;
static String textToEncode;
[Code]...
View Replies
View Related
Mar 14, 2014
When I am invoking a servlet class file from my HTML file instead of displaying output in my browser it is downloading my output as a file..Why it is?..
View Replies
View Related
Jul 24, 2014
I'm currently working on a program that is supposed to translate morse code and then display the result and I'm stuck, my program has tons of errors when I try to compile.
public class Assignment10
{
public static void main ( String [] args )
{
String str = Input.getString("Please type in a word");
char [] letters = {'a','b','c','d','e','f','g',
[Code] .....
View Replies
View Related
Sep 12, 2014
I need to create a simply application that would display the results of two dice thrown five times and the total of those results. This is shown below in the attached file.
The problem is, I have a do-while loop that loops 6 times. Inside the loop, I have 2 random.nextInt(5) that generate random numbers. But how can I output the total? How can I make a variable equal to the sum of the two random numbers if the two random numbers are located inside a do-while loop?
Attached below is also the code I have thus far.
(Attached below is both files: what it needs to look like, and what it currently looks like)
View Replies
View Related
Oct 23, 2014
My mad lib program was able to store my three notepad text: noun, verb, and story. I would like to find out what is the best way to make it display my result randomize my story from notepad? once everything is stored?
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import java.util.*;
public class StoryProject extends JFrame implements ActionListener
[Code] .....
View Replies
View Related
Oct 26, 2014
Write a program that will read two numbers and an integer code from the keyboard. The value of the integer code should 1, 2, 3, 4. If the value of the code is 1, compute the sum of the two numbers. If the code is 2, compute the difference (first number minus second). If the code is 3, compute the product of the two numbers. If the code is 4, and the second number is zero, compute the quotient (first divided by second). If the code is not equal to 1,2,3,4, display an error message. The program is then to display two numbers, the integer code and the computed result to the screen
here is the code that I have so far:
public static void main(String[] args) {
Scanner read = new Scanner (System.in);
int num1, num2, code, sum;
System.out.println("Please enter a number");
num1 = read.nextInt();
[Code] .....
View Replies
View Related
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
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
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
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
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
Mar 18, 2014
Write a class named FileDisplay with the following methods:
1.) constructor: the class's constructor should take the name of a fil as an arugment.
2.) displayHead: This method should display only the first five lines of the file's contents
Here is the following code I have made so far
import java.io.*;
public class FileDisplay
{
private String filename;
public FileDisplay(String Filename) throws IOException
[Code] ....
First, in my constructor I have taken in an argument and used that argument to open up an output file. Meanwhile, I'm trying to work n the displayhead method to print out information and to read data to. I haven't opened up my input file yet, but I'm not understand how can I read a print data to an output file. in
public void displayHead()
{FileWriter file=new FileWriter(Filename)}
do I make create another instance of the filewriter class to output data?
In simple words, suppose to I want to display some messages on my output file in the displayhead function. Since I already have opened up the file in the constructor, how do I combine that in this method...
View Replies
View Related
Apr 3, 2013
public class NewClass4 {
public static void main(String[] args) {
int a = 1;
int b = 2;
int c = 3;
a += 5;
b *= 4;
c += a * b;
c %= 6;
System.out.println("a = " + a);
System.out.println("b = " + b);
System.out.println("c = " + c);
View Replies
View Related
Jan 4, 2015
I've made a class called Car with a method which will tell me a category for the engine size regarding the actual size (which I've included in the main just so I could see if it works) but everytime I test it I get an error.
public class Car {
public String b;
public String c;
public double es;
public double cs;
public String getCategory() {
if (es < 1.3)
[Code] ....
Figured it out. Was missing parenthesis on audiCar.getCategory();
View Replies
View Related
May 11, 2014
import javax.swing.*;
import java.awt.*;
public class PRJ04 extends JFrame {
public static void main (String [] args) {
PRJ04 frmApp = new PRJ04();
PanelChart pnlChart = new PanelChart();
[Code] .....
When I comment out the adding and setting of the pnlChart on my main driver, the pnlPopulationInputs shows up fine, and it runs ok. When I add the pnlChart I get errors like crazy and a white screen. My errors:
Exception in thread "AWT-EventQueue-0" java.lang.ArithmeticException: / by zero
at PanelChart.drawChart(PanelChart.java:45)
at PanelChart.paintComponent(PanelChart.java:24)
at javax.swing.JComponent.paint(JComponent.java:1054)
[Code] ....
Once more with this one, I refer back to our in class example. Our programs are set up the same, yet he has no issues with the "/ by zero" exception.
View Replies
View Related
Nov 17, 2014
I have done 90% of the coding however i am stuck with producing the output, i just cant get the user fields to show.
I have attached a picture of the output that is required. The program consists of two classes i have attached the database class, and have inserted my coding below.
import java.sql.*;
import java.io.*;
import java.util.*;
public class QueryDB {
private Connection con = null;
String userID,
[Code] ...
Attached image(s)
View Replies
View Related
Feb 19, 2014
I have to create a program that takes a list of student names and grades and then takes the 2 highest scores and reads them, but the result won't show. I'm pretty sure it's because I'm not sure about how to code the last part which should output the results. Here's my code.
import java.util.Scanner;
//Reads input and outputs 2 highest scores
//for loop. nested for.
public class HighestScores {
public static void main(String[] args) {
//create values
String studentName;
[Code] .....
View Replies
View Related
Nov 20, 2014
I have to get my output to show as per the image attached i am very close but not there yet. I have also attached the database where i extract my information from
/*
Program Name: QueryDBDB.java
Purpose: to build an initial database for the stocktrakcer application
*/
import java.sql.*;
import java.io.*;
import java.util.*;
public class QueryDB
{
private Connection con = null;
String userID,firstName,lastName,name,symbol;
public QueryDB() throws Exception
[Code] .....
Attached image(s)
View Replies
View Related
Jan 11, 2015
My program is attempting to:
1. ask user to input a decimal
2. output 1 - confirms the input
3. output 2 rounds the input value to the nearest integer.
Here is what I have so far:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.util.Scanner;
public class IT145Exercise13 {
static Scanner console = new Scanner(System.in);
[Code] .....
Results with input of 5.25:
run:
Enter a decimal:
5.25
You entered 5.25
The integer value is 5 YES however,
BUILD SUCCESSFUL (total time: 6 second)
However, if the input is 5.95 here are the run results:
run:
Enter a decimal:
5.95
You entered 5.95
The integer value is 5 Here I expect 6
BUILD SUCCESSFUL (total time: 6 second
Not sure how to ask the output of the variable integerOut to be rounded to the nearest integer?
View Replies
View Related
Jan 3, 2015
i need to seek all data in result set one by one.i excuted a query which i don't know the result of it...it could be have one result in result set or 10 result.i tested this code :
PHP Code:
Query = "select * from book"
while (Rs.next)) {
row.add(new Book(Rs.getString(i)));
//Book is a class
}
but didn't work. do we have any other way we seek the result set without rs.next() ???
View Replies
View Related
Apr 18, 2015
Right now it displays a number like this "$25.0" and I want it to display it like this "$25.00" and don't know how to do it.
View Replies
View Related