calculate « Number « Java Data Type Q&A





1. Trying to calculate the 10001st prime number in Java    stackoverflow.com

Greetings. I am doing Problem 7 from Project Euler. What I am supposed to do is calculate the 10001st prime number. (A prime number being a number that is only divisible ...

2. Calculating complex numbers with rational exponents    stackoverflow.com

Yesterday I created this piece of code that could calculate z^n, where z is a complex number and n is any positive integer.

--snip--
float real = 0;
float imag = 0;

// d is ...

3. How to calculate Lucas Numbers in Java    stackoverflow.com

Hey guys, I am a starting programmer and need to program an application in java which ask for a number and then prints the first n number of Lucas Numbers. for ...

4. How to calculate mean, median, mode and range from a set of numbers    stackoverflow.com

Are there any functions (as part of a math library) which will calculate mean, median, mode and range from a set of numbers.

5. Calculate the number of times to divide by two    stackoverflow.com

Greetings. I have a java method that I consider expensive, and I'm trying to replace some calls to it with a mathematical expression. Problem is, I suck at math. I mean really ...

6. calculate average based on 1 number only    stackoverflow.com

How to calculate percentage ( or average) when You have dividend but not deviser?

7. Java: Calculate number of do/while loop    stackoverflow.com

So I've made this guessing game where you the computer randomly picks a number between 1-100 and the user have to guess the correct number. I've made that working, now I ...

8. how to calculate number of lines of code in a java web project?    coderanch.com

Google for "java static source code analysis" and you'll find a bunch of tools that will give you LOC and much more. It's also a pretty simple matter to just read all the files in a directory tree and count lines yourself. Do you have to count non-comment lines or anything tricky? That said, many of us would be very skeptical ...

9. calculating the number of business minutes in a month    coderanch.com

If the business is open from 8:00 am to 5:00 pm Monday through Friday, is there a simple way to calculate the number of business minutes in February, 2005, and in July, 2006, and the months between. Not only are the number of days different, but the number of business days are different from month to month as different days fall ...





10. calculating number of days    coderanch.com

Hello again. New homework assignment.... User is prompted one at a time to enter in the following; -arrival month (1-12) -arrival day (1-31) -arrival year -departure month (1-12) -departure day (1-31) -departure year (assume valid data) application displays arrival date, departure date, daily rate (a constant of $115.00), total price and number of nights. Create a class that defines a reservation. ...

11. Calculating a number in a category    coderanch.com

I have a slight problem here. I am writing a program that reads in a lot of hurricane data. As you can see in my code, I have read in information from the hurricane category array(this array keeps track of what category each hurricane was). I am trying to figure out how many (what number) of hurricanes there was in each ...

13. program to calculate male to female ratio of a given number    coderanch.com

/** * Write a description of class HeadsOrTailsV1 here. * * @author (your name) * @version (a version number or a date) */ import java.util.Scanner; import java.util.Random; public class PopulationRatio { public static void main(String [] args) { Scanner in; in = new Scanner(System.in); System.out.println("Enter the number of People: "); int numberOfPeople = in.nextInt(); int numberOfMen = 0; int numberOfWomen = ...

15. Calculating the number of user inputs?    coderanch.com

Sorry about that... I am putting together a program that uses user input the update the position of a point within a square. The user is prompted on a loop to input a direction using letters such as up, down, left or right (not using arrows) until such time as the point reaches the boundary of the square. Upon reaching the ...

16. Calculating the average of an unknown amount of numbers    coderanch.com

Working on a programming question from "The Art and Science of Java". I need to allow the user to input any amount of numbers they want and then when they finish produce the average of their numbers. I wrote a program where I add all of the numbers input but then I'm stuck on the division part because I don't know ...





17. Using percent Modulus to calculate total number of even numbers from user input    coderanch.com

Ok my assignment for class is to use the percent mod to calculate the total number of all the numbers and the total number of even numbers only. This should be done by using the user's input of their number. the % "mod" operator Input: The first line of input will be a random list of integers the user will put ...

18. Program in Java To calculate GCD of n numbers.?    java-forums.org

gcd n When I started contemplating the problem, I got the feeling a brute force method would be computationally demanding. Although my initial research suggested the problem was np-complete, I also found that Algorithm 386 by Bradley is linear in time and space. Many of the sources for the paper are academic and require a professional subscription or access as a ...

19. Am having trouble to calculate number of methods in class    java-forums.org

This is the code i have tried to count total number of public methods declared in any class entered as input to the class. At compilation its giving no error but when i run it displaying ClassNotFoundException ... Some body please fix my code please i waste enough time and final came to conclusion that i need some assistance from an ...

20. Java application to calculate and display the cost of a number of tickets according    java-forums.org

Java application to calculate and display the cost of a number of tickets according to the rules: 7 per ticket for children (age < 18) 10 per ticket for adults (age between 18 and 59) 8 per ticket for senior citizens (age > 59) The customer enters two whole numbers age and tickets (the number of tickets required) ...

21. Calculating prime factors for a number    forums.oracle.com

Look at your while loop. It runs until n%i isn't zero...but you change the value of n, so that doesn't work like it should. You say it doesn't work for 6...look at your code, see what happens if you put in 6. You start with i = 2, so it tests 6%2 == 0 which is true. So it prints out ...

22. how to calculate square root a number?    forums.oracle.com

23. Am having trouble to calculate number of methods in class    forums.oracle.com

This is the code i have tried to count total number of public methods declared in any class entered as input to the class. At compilation its giving no error but when i run it displaying ClassNotFoundException ... Some body please fix my code please i waste enough time and final came to conclusion that i need some assistance from an ...

24. big numbers calculate?    forums.oracle.com

25. calculate number of months    forums.oracle.com

Possibly you need little more than some arithmetic. We don't have "leap months", so there are exactly 12 per year. Every year. Suppose you worked in an egg factory. The cartons roll past you stamped in numeric order. You notice that box number 2008 had the first half dozen eggs missing. 2009 was ok (had the complete 12). And 2010 only ...

27. i am not able to calculate two numbers    forums.oracle.com

import java.util.*; import java.awt.event.*; import javax.swing.*; import java.awt.*; import java.io.*; public class Calc { private JTextField d1; private JFrame frame; String x,z,o; public static void main (String[] args) { Calc g = new Calc(); g.go(); } // close main public void go() { frame = new JFrame("Simple"); JPanel mainPanel = new JPanel(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Font bigFont = new Font("sanserif",Font.BOLD,24); d1 = new ...

28. How to get correct number of hours from a total calculated hours    forums.oracle.com

Hi all I'm trying to calculate the number of actual hours. so the hours look like this A: 1hr 30min B: 1hr 40min if i add those up i get C: 2hr 70min (ie 1.30+1.40=2.70) however, I want to actually display the actual hours which is 3hr 10min I had the idea of turning the hours into seconds ie 1.30+1.40=2.70 ----> ...

29. java.util.GregorianCalendar -Wrongly calculated number of days in the month    forums.oracle.com

Hi, I got a problem with GregorianCalendar. I couldn't find any informations about behavior like this in a bug database. I'm instantiating a gregoriancalndar object like that: java.util.Date date = new java.util.Date() ; java.util.GregorianCalendar cal = new java.util.GregorianCalendar() ; cal.setTime(date) ; Everything ok? I think yes. Problems appear later. For example in 2007 in July and August we have 31 days, ...

30. How to calculate the number of resize operations by StringBuffer    forums.oracle.com

StringBuffer default size is 64 characters. I would like to calculate how many times a StringBuffer would need to be resized if this size is not amended to achieve a particular final size. e.g. I expect my total StringBuffer to be 40,000 charcters long - how many times would it need to be resized to reach this capacity? Can someone provide ...

31. How to calculate Lowest number using While or if    forums.oracle.com

You have declared six variables to store your six numbers. What happens if the requirements change to store 100 numbers? Are you going to change your program to declare another 94 variables? A better solution wouold be to store the numbers in an array. Declare a variable to store the lowest number. Is this what n is for? If so give ...