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
ADVERTISEMENT
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
Feb 20, 2014
How would I compare the square of the square root of any number. The difference in these values is due to the rounding error in Java.
Example: Enter number 2
The answer I should get is: 2.000000000000004
Round off error: -4.440892
View Replies
View Related
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
May 14, 2009
This is a mathematical problem. I got one of the equations I need to compute down to
n^(1/6)
Or the 6th root of n.
Now the Java code I have for this is as follows, since Java has no nth root function I'm raising it to a power of a 1/6.
System.out.println(Math.pow(64.0, 1/6));
Now, the only thing it will print is 1.0
However the 6th root of 64 is 2!!!!
View Replies
View Related
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
Jan 3, 2015
My code compiles and runs just fine, i'd just like to get creating a small square box that shows number of words used next to the "word count = ". i'd wanto to press the count words button to count and show the number in the square box. here is my code.
import javax.swing.*;
import javax.swing.text.*;
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
public class wordCount extends JFrame implements ActionListener
[Code] .....
View Replies
View Related
Sep 2, 2014
Some algorithm in computing the square root of a number without using any loops?
View Replies
View Related
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
Aug 31, 2014
I'm trying to create a cursor for a game that moves square by square. While it will move to the next square, though, it leaves the image of the previous cursor on the last square it was on.
As a visual explanation, this is what the program looks like on launch:
This is what it's suppose to look like after you press the right arrow key once (made by forcibly changing launch coordinates):
And this is what it actually looks like after you press the right arrow key once:
Here is the code for the program:
package cursortest;
import javax.swing.*;
import java.awt.*;
import javax.imageio.*;
import java.io.*;
import java.awt.event.*;
public class CursorTest extends JPanel implements KeyListener{
[Code] ......
I'm fully aware that I could just use g.clearRect on the area and remove it for sure, but I know for a fact I shouldn't have to as I have another program I made a long time ago that tried to do something similar without needing to resort to that.
View Replies
View Related
Jun 19, 2014
You are to write a parallel program that will receive a large array of unsorted integers containing digits from 0 to 99. The program will have to calculate the SUM and AVERAGE of ODD number digits between 25 and 75 (inclusive).
The user may specify the size or the array and the total processor that the machine has. The size of the array must be divisible by number of processor. Based on the given size, the computer will generate random integer numbers automatically to populate the array.
The program should display the status of the calculation for each processor. The result should be displayed after all calculations are completed.Error messages should be displayed appropriately
a) Write a sequential (non-parallel) program that will accomplish above task.
b) Write a concurrent (parallel) program that will produce the result of the above task.
View Replies
View Related
Apr 29, 2014
Write a recursive method that calculates the Nth number in the Fibonacci sequence. The first and second numbers in the sequence (the base cases) are both 1. After that, each subsequent number is the sum of the previous two. Stated a bit more formally:
fib(n)={1fib(n−1)+fib(n−2)n<2otherwise
For example, here is the first few numbers in the sequence:
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
Your fib method should be part of a class named Fibonacci. In addition to the fib method, the Fibonacci class should have a main method that calls fib(9). If the result doesn't equal 34, you should print an error message. Otherwise, it should print out a message saying that it was successful.
After writing your Fibonacci class, answer the following question: How many times is the fibonacci method called when calculating the 5th number in the sequence?
View Replies
View Related
Mar 16, 2014
lines 7, 8, &12 "primes" are underline in red (prime cannot be resolved) is what pops up when i hover over the x's.
i don't get why that is.
package assignment7;
public class Exercise3
{
public static void main(String[] args)
{
Prime.setSize(1000);
for (int p = Primes.next(); p < 30; p = Primes.next())
[Code]...
View Replies
View Related
Mar 17, 2014
Lines 7, 8, &12 "primes" are underline in red (prime cannot be resolved) is what pops up when i hover over the x's.
I don't get why that is.
Java Code :
public class Exercise3
{
public static void main(String[] args) {
Prime.setSize(1000);
for (int p = Primes.next(); p < 30; p = Primes.next()) {
int n = (int)Math.round(Math.pow(2,p)) - 1;
System.out.printf("%d 2^%d-1%d", p, p, n);
if (Primes.isPrime(n))
[Code] ....
View Replies
View Related
May 2, 2014
I'm trying to write a java code that calculates the varince of a set of number and I wanted to know if this is the proper way to do it.
for (int i = 0; i <= (myArray.length - 1); i++){
variance = Math.pow((myArray[i] - average), 2);
}
View Replies
View Related
May 1, 2014
I have to create a program that calculates the nth Fibonacci number and returns that to the user. Fibonacci said his number sequence would describe the ideal breeding patterns of immortal rabbits. So, you are going to make this vision a reality.
First, take in a numeric value from the user and calculate that value in the fibonacci series. Next, find an image of a rabbit and display the image on a GUI (put the image as an icon on a label!) the number of times returned by the algorithm (Put all the aforementioned labels on one panel with FlowLayout!).
You need to remove the old images from the Panel. Probably the easiest way to do this is to create a whole new panel and remove the old one (hint: the remove method of JPanel should come in handy)
You could use an array of JLabels
You will need to create a new JLabel and add each member of the array to the panel
I should be able to scroll to see any images that are off screen
I am having difficultly on to making the array list for JLabel, and getting the Fibonacci sequence to show the pictures of rabbits. Below is my current code.
import java.awt.FlowLayout;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Rabbit extends JFrame
[Code] ....
View Replies
View Related
Jan 4, 2015
This is supposed to get a certain number of items, and then calculate how much every item costs. It adds up the sum of those prices and checks if it is over 150$, if it is, it returns true, if it's not, it returns false.
import java.util.*;
class Cust
{
public static boolean DelPay (int a) {
Scanner reader=new Scanner (System.in);
int b,s=0;
for (int i=1;i<=a;i++) {
b=reader.nextInt();
s=s+b;
}
if (s>150)
return true;
return false;
}
}
View Replies
View Related
Jun 11, 2014
You are to write a parallel program that will receive a large array of unsorted integers containing digits from 0 to 99. The program will have to calculate the SUM and AVERAGE of ODD number digits between 25 and 75 (inclusive). The user may specify the size or the array and the total processor that the machine has. The size of the array must be divisible by number of processor. Based on the given size, the computer will generate random integer numbers automatically to populate the array.
The program should display the status of the calculation for each processor. The result should be displayed after all calculations are completed.Error messages should be displayed appropriately
a) Write a sequential (non-parallel) program that will accomplish above task.
b) Write a concurrent (parallel) program that will produce the result of the above task.
View Replies
View Related
Nov 11, 2014
I'm trying to print out the results of a program that calculates the number of seats the parties will get in an election.I have to print the partial results and the national results.
I can print te number of seats per party in each constituency, but how can i sum all seats per party in each constituency and print the national results?I'm working with vectors, which I know it might not be the best option, but everything is working, except the fact that I can't loop throuhg the vector and retrieve the total sum per party.Like, adding the seats for labour party in Constituency A and B and C, etc, and print the sum. And do the same for conservative party.Is it possible, or doIhave to create a method in Parties class to solve the problem?
This is what I have now.
for (Parties p : h.geral) {
show += String.format("Constituency - %5s - %5s - %d%n",
p.getConstituency(), p.getParty(), p.getNum_seats());
}
View Replies
View Related
Apr 27, 2014
I am trying to make a program so that the user has to enter a number for the width and length and it will give the area and perimeter:
import java.util.* ;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class jframe extends JFrame {
private static final int WIDTH = 400;
private static final int HEIGHT = 300;
[Code] ....
It is giving me an error saying that the ExitButtonHandler and ebHandler do not have classes but I don't understand why.
View Replies
View Related
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
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
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
Nov 25, 2014
I'm having a small issue with my output on my code. here is what my output is: The magic value for your square is 34, which means that every row, column and diagonal of your square must add up to that number.
Please enter the 4 values for row 0, separated by spaces: 1 2 15 16
Please enter the 4 values for row 1, separated by spaces: 13 14 3 4
Please enter the 4 values for row 2, separated by spaces: 12 7 10 5
Please enter the 4 values for row 3, separated by spaces: 8 11 6 9
Checking square for problems:
DIAG: VALID
ROWS: VALID
COLS: VALID
RANG: VALID
MAGIC: No
MAGIC should be YES. However i keep getting it saying no.This is the correct output..The magic value for your square is 34, which means that every row, column and diagonal of your square must add up to that number.
Please enter the 4 values for row 0, separated by spaces: 1 2 15 16
Please enter the 4 values for row 1, separated by spaces: 13 14 3 4
Please enter the 4 values for row 2, separated by spaces: 12 7 10 5
Please enter the 4 values for row 3, separated by spaces: 8 11 6 9
Checking square for problems:
DIAG: VALID
ROWS: VALID
COLS: VALID
RANG: VALID
MAGIC: YES
Here is my code..
import java.util.Scanner;
public class pdonahue_Magic {
public static void main(String args[]) {
int[][] theSquare = new int[4][4];
Scanner s = new Scanner(System.in);
System.out.println.
("The magic value for your square is 34, which means that every row, column and diagonal of your square must add up to that number.");
System.out.print("Please enter the 4 values for row 0, separated by spaces: ");
theSquare[0][0] = s.nextInt();
theSquare[1][0] = s.nextInt();
theSquare[2][0] = s.nextInt();
theSquare[3][0] = s.nextInt();
[code]....
View Replies
View Related
Oct 17, 2014
Do I want to make something like this:
*****
*.....*
*.....*
*.....*
*****
I am stuck, I have made a code that creates this and don't know how to complete it.
*****
* *
* *
* *
*****
Code:
class Main {
public static void main( String args[] ) {
System.out.print("#Enter number of stars :");
int stars = BIO.getInt();
[Code] ....
View Replies
View Related