Calculate Radius Of A Pond?
May 31, 2014
This is the code
public class PondRadius {
public static void main (string[] args) {
//Calculate the radius of a pond
//which can hold 20 fish averaging 10 inches long
int fishCount = 20;//number of fish in pond
int fishLength = 10;// Average fish length
int inchesPerFoot = 12;//number of inches in one foot
[Code] ....
And here is the error or exceptions i received
C:javaLesson1>javac PondRadius.java
PondRadius.java:23: error: ')' expected
System.out.println("To hold" + fishCount + fish averaging " + fishLength +" inch
es long you need a pond with an area of
" +
[Code] .....
View Replies
ADVERTISEMENT
Mar 5, 2014
I am doing an assignment that is asking for the user to put in the radius of a circle and the program figures out the area, diameter and circumference. It is using 2 different java programs to accomplish this. One with the info on how to get area, diameter and circumference and one is the demo that runs the program. I keep getting errors on my demo.
// Circle Class
public class Circle {
private double rad;
private double Pie;
private double area;
private double diameter;
[Code] .....
View Replies
View Related
Jan 29, 2015
How do you use power of math. I'm trying to write a calculator to calculate the volume of a cylinder by asking the user to enter the height and radius but when I use pow(2) it doesn't work. I imported java.lang.math class so i dont have to keep using math. for now my code runs just fine since I'm using radius * radius but I would really luv to use the power instead times each other when i have to use higher powers.
import java.util.Scanner;
import static java.lang.Math.*;
public class Lab2 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
[Code] .....
View Replies
View Related
Jul 8, 2015
I am trying to create a user defined Exception. I am using a hard-coded value in the constructor of circle class at the time of object creation.But in the constructor this value becomes 0.
import java.lang.Exception;
import javax.swing.*;
class InvalidRadiusException extends Exception{
private double r;
public InvalidRadiusException(double radius){
r = radius;
[Code] ....
Due to this its always generating InvalidRadiusException even if i am supplying a non-zero non-negative value.
View Replies
View Related
Oct 24, 2014
I have to print points on a circle in increments of -0.1, but when I use a number larger than 1.3, the list stops at 0.1 larger than negRadius, and I don't know why. (Assume the center is (0,0))
public class PointsOnACircleV1
{
public static void main(String[] args)
{
double radius = 1;
[code]...
View Replies
View Related
May 1, 2015
Write a program that draws 20 circles, with the radius and location of each circle determined at random...... Two circles overlap if the distance between their center points is less than the sum of their radii...
There may be many problems with the code in general but what I'm struggling with is the distance and the totalradius portion. Visually, its inaccurate.
import java.awt.*;
import javax.swing.*;
public class CircleTest extends JPanel {
Circle []circles;
Circle []circleCenter;
Circle []all;
private int distance, totalradius, dx, dy;
private int radius,x,y;
[Code] ....
View Replies
View Related
Oct 8, 2014
I am supposed to write a Tester to get the current volume of a balloon that starts with a radius of 0 after it is inflated.This is the balloon:
public class Balloon
{
private double savedRadius;//instance variable
/**constructor!!
Constructs a balloon with a radius
*/
}
[code]....
View Replies
View Related
May 29, 2014
(Corner point coordinates) Suppose a pentagon is centered at (0, 0) with one point at the 0 o’clock position. Write a program that prompts the user to enter the radius of the bounding circle of a pentagon and displays the coordinates of the five corner points on the pentagon. Here is a sample run:
Enter the radius of the bounding circle: 100
The coordinates of five points on the pentagon are
(95.1057, 30.9017)
(0.000132679, 100)
(-95.1056, 30.9019)
(-58.7788, -80.9015)
(58.7782, -80.902)
What we know , we know both the radius of the circle(user inputted) and the side of the pentagon from formula (double side = 2 * radius * Math.sin(Math.PI/5)) .We also know that one point is (0 .100) Also i know that the distance between 2 points is Math.sqrt(Math.pow(x1 - x2 ,2) - Math.pow(y1 -y2 ,2)) .
There might be other ways to solve it but this is my best bet trough i dont remember how to solve linear equations of the form x^2 + y^2 = - radius and radius ^2 = x^2 + (y - 100) ^ 2..
The solution i found is using the radius from the center to the point we want to find out and using the radius to the point we already know ( 0 .100) but i have to solve that damn equation first ...
View Replies
View Related
Sep 28, 2014
I made a MVC calculator. I was wondering if you could take a look at my design and if I was on track. I am still working on getting it to actually calculate something. All the buttons respond and print text on the JTextField but it is not calculating.
package calculator.MVC;
import javax.swing.JButton;
import javax.swing.JTextField;
public class CalculatorModel {
private int sum;
private int number;
private char opt;
[code]....
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
Feb 13, 2015
So I have this code to calculate the lowest value of an array:
public class Exercise1 {
public static void main(String[] args) {
int[] theArray = {1/*/,2,3,4,5,6,7,8,9,10/*/};
int result = Exercise1.min(theArray);
System.out.println("The minimum value is: " +result);
[code].....
and I need to write an exception class that should be thrown if the array does not hold any elements.
View Replies
View Related
Oct 19, 2014
I have been tasked with creating an invoice (school assignment). Part of the calculations is creating an interest depending on the amount of days between the current date entered, and invoice date entered (The program prompts the user to enter both the current and invoice dates by asking for the day, month and year).
We are also supposed to set the contructor to a default date of 1/1/1900.. but I don't know how or where to code that.
How to calculate the difference between the CurrentDate and Invoice. I have displayed the dates to the user as follows.
public void displayDate() {
System.out.println("
Today's Date: " + month + "/" + day + "/" + year);
}
public void displayInvDate() {
System.out.println("
Invoice Date: " + invMonth + "/" + invDay + "/" + invYear);
View Replies
View Related
Mar 26, 2015
how does the program know to calculate for only one year?
public class Interest2 {
public static void main(String[] args) {
double principal; // The value of the investment.
double rate; // The annual interest rate.
double interest; // The interest earned during the year.
[code]....
View Replies
View Related
Nov 21, 2014
i need to calculate the minimum and the maximum, actually it seems to be easy but, the minimum should be the smallest number but 0..this is my code
Java Code:
Scanner s = new Scanner (System.in);
int max = 0 ;
int min = 0 ;
System.out.println(" Please enter 3-5 numbers");
int a = s.nextInt();
int b = s.nextInt();
int c = s.nextInt();
int d = s.nextInt();
int e = s.nextInt();
[code]....
View Replies
View Related
Mar 31, 2015
there are the normal parking rates with two condition using two difference code and two difference calculator method. the fees for the two code also different.i need to display the code, enter time. enter out, and parking charge. i have a problem with the processor method.
View Replies
View Related
Aug 3, 2014
So I wrote a method that simply calculates the sum of all integers between 1 and a given integer n. The method works fine however, as n gets big the solution will have time and space problems. Some I'm just curious if there is a better method than my iterative one that would produce a better Big O value.
public static int sum(int n)
{
int total = 0;
for (int i = 1; i <=n; i++)
total += i;
return total;
}
View Replies
View Related
Jan 3, 2014
I would like to change the precent from *1.17 (17%) to calc of precent like this :
3% + 5% + 5$
For example :
The resault is 10$ - i want to get :
10$ +3%(0.3$) + 0.5% (0.51$) + 5$ = 15.81$
How i change this line to this calc
if(results[i].getSite()=='Xxx'&&XPrice==0)
{
XPrice =(results[i].getPrice() *1.17);
}
}
View Replies
View Related
Oct 16, 2014
I'm new to java and i'm trying to figure out how to calculate power in java using the for loop.
The geometric sequence is (d*c^(n-1)).
So it goes d, d*c^1, d*c^2,......., d*c^(n-1)
??????for (i=1; i<=n; i++){
result
}????????
How to program this. how do i write this using for loop?
View Replies
View Related
Jun 18, 2014
Write a program called ComputePi to compute the value of pi using the following series expansion. you have to decide on the termination criterion used in the computation(such as number of terms used or the magnitude of an additional term). Is this series suitable for compute pi?
PI=4*(1-(1/3)+(1/5)-(1/7)+(1/9)-(1/11)+(1/13)-(1/15)+.......)
View Replies
View Related
Jan 19, 2015
I have for example a letter code "EECC"...Now i want to have a good loop that checkes if the code typed in by the player matches or not? For example if player types CECE it should say it matches because C occurs 2 times and E occurs 2 times. This function must return than 4.If player types CEEE, it must return 3, because the code has 2 C en 2 E, player input is 1 C and 3 E, the last E is wrong.I've tried some loops with breaks but they all fail..
for example:
String test = "EFCC";
String test3 = "ECEC";
for(int i = 0; i < test.length(); i++){
matchFound = false;
[Code] .....
This returns 2 instead of 3.
View Replies
View Related
May 2, 2014
The first is MyArray Class (You can either use an array or an arrayList)Create a class called LastNameFirstNameMyArray according to the UML diagram. This class will allow a user to enter 5 integer values into an array(or object of ArrayList<Integer>). It contains methods to find min and max values and calculate the mean for the data set.
LastNameFirstNameMyArray - data[ ] : int (or data : ArrayList<Integer> )
- min : int
- max: int
- mean : double + LastNameFirstNameMyArray()
+ findMin() : void
+ findMax() : void
+ calculateMean(): void
+ toString() : String
Attributes:
data[]the array which will contain the values or data<Integer>the arraylist which will contain the values
minthe minimum value among the values in the arraylist
maxthe maximum value among the values in the arraylist
mean the arithmetic average of the values
Methods:
You need to implement the constructor LastNameFirstNameMyArray(), which populates 5 values. In addition, the constructor should call findMin() and findMax(), and also calculateMean().
Methods:
LastNameFirstNameMyArray()the constructor. It will allocate memory for the array (or arraylist) of size 5. Use a for loop to repeatedly display a prompt for the user which should indicate that user should enter value 1, value 2, etc. Note: The computer starts counting with 0, but people start counting with 1, and your prompt should account for this. For example, when the user enters value 1, it will be stored in indexed variable 0. The constructor should populate 5 integer values, call findMin() and findMax(), and also calculateMean().
findMin()this is a method that uses a for loop to access each data value in the array (or arraylist) and finds the minimum value. The minimum value is stored into min.
findMax()this is a method that uses a for loop to access each data value in the array (or arraylist) and finds the maximum value. The maximum value is stored into max.
calculateMean()this is a method that uses a for loop to access each data value in array (or arraylist) and add it to a running total. The total divided by the number of values (use the length of the array), and the result is stored into mean.
toString()returns a String containing data, min, max, and the mean.
Task #2 TestMyArray
1. Create a LastNameFirstNameTestMyArray class. This class only contains the main method. The main method should declare and instantiate a LastNameFirstNameMyArray object.
2. Compile, debug, and run the program. Then, it should print out the contents, the min, max, and mean of the data.
and the second is A theater seating chart is implemented as two-dimensional array of ticket prices, like this:
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
10 10 20 20 20 20 20 20 10 10
10 10 20 20 20 20 20 20 10 10
10 10 20 20 20 20 20 20 10 10
20 20 30 30 40 40 30 30 20 20
20 30 30 40 50 50 40 30 30 20
30 40 50 50 50 50 50 50 40 30
Write a program that prompts the users to pick either a seat or price. Mark sold seats by changing the price the 0. When a user specifies a seat, make sure it is available. When a user specifies a price, find any seat with that price.
Note: Assume that if the user enters 1 for the row and 1 for the seat, the yellow marked sit will be sold.
View Replies
View Related
Feb 9, 2015
i finished up a project here and seem to be running into some issues. I figured its my notation, when i ask a user to enter a number, if its below 10, it should *only* print "No Coupon." but what appears to happen is that the program prints "No Coupon" Plus the "discount coupon and % of purchase."
import java.util.Scanner;
public class assign1c { /* Start of Class 1c */
static double cost;
static double coupon = 0;
static String x = "No coupon";
public static void main(String[] args) {
// TODO Auto-generated method stub
[code]...
View Replies
View Related
Jan 28, 2014
It's suppose to generate a table with the month, and the new amount of the CD. Right now, the program generates a continuous table for months, but it doesn't update the value of the CD.
import java.util.*;
public class Excercise04_31 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
[Code] ....
View Replies
View Related
Dec 11, 2013
I need to know the sinus or angle between two points (x1,y1) and (x2,y2).
Any formula to calculate this?
View Replies
View Related
Oct 24, 2014
double price;
String PriceStr;
int quantity;
String QuantityStr;
PriceStr = JOptionPane.showInputDialog("Enter the price: ");
price = Double.parseDouble(PriceStr);
QuantityStr = JOptionPane.showInputDialog("Enter the quantity: ");
[code]....
So i tried to make it allows the user can continue pick the option and calculate the total of every time they select the option, mine is only 2 times.
View Replies
View Related
Feb 25, 2014
Two machines are connected in a LAN & Sharing Files in between them.
Everything is Working Fine but now i want to calculate the Copying Speed/data transfer Speed between them.
View Replies
View Related