I have an assignment to complete where I have to develop a Java Console application in Eclipse which accepts regional zone information for premises based upon addresses provided. The program needs to figure out which geographical zone each customer lives in and based upon their age, set a priority rating.
The zones (which is the Belfast and the directions) and sub-zones (which are the Postcode such as "BT1" are:
1.Display a count of addresses within a user defined geographical zone. 2.Display all information for customers within a user defined geographical zone. 3.Display a complete set of captured data. 4.Display a prioritized list of customer details within each geographical zone. 5.Display a count of customers within each geographical zone.
Below is the code I have created so far for it.
package assignment1;
import java.io.BufferedReader; import java.io.InputStreamReader; public class Assignment1 { private static InputStreamReader input = new InputStreamReader(System.in); private static BufferedReader reader = new BufferedReader(input);
[Code] .....
The main issue I'm having is to make sure that data like address and customer counts, and customer details appear only for the selected areas.
The purpose of this function is to use a Movie object and a binary search tree to find all movies that have been read in through a file that have a certain rating (G,PG,PG-13,R). The error I am getting is that it seems I am not traversing fully through the tree and therefore only some movies with the rating I search for are output, not all of them with that rating. I have tried figuring out why this is happening and at first I thought my tree was unbalanced, but I am sure it is simply because I am not traversing the tree correctly. I think my implementation in the main is close to what I need but it needs some tweaking. This is my BST class which I created and required to use for this purpose.
public class BinarySearchTree { /** * The head of the tree. */ private Node root; /** * Constructor that declares the head of tree to null. */ public BinarySearchTree() { root = null; } /** * Returns null if head of tree is empty. * @return null if head of tree is empty. */ public boolean isEmpty(){
We have been given an assignment to create a small library, with the following classes Library, Book, Author and Copy. With a given class Biblio which has predefined code and adds the books to the class book in an arraylist in Class Copy.
The UML Domain is attached so you know the flow of the classes Everything is working fine and the generated output is correct.
There is just one method in class Library that is not working, the int method has to count the number of Copy's based on the Class Book (String):
I have to go through the Arraylist in Class Copy and look for a specific book and return the number of copy's.
I have tried multiple steps using a for loop Now I have found a similar post the uses hashset, I have tried below code but the return comes back with 0. (There are 3 copy's)
I was trying to come up with the design for a library. Here are the requirements:
The library maintains a record of books and its members. It allows members to check out books. Books can be searched by author name or title. The books are classified into 4 categories - General, Sports, Politics, Business.
I've come up with this initial design:
Classes:
Category (enum)BookMemberLibrary Category Attributes: SPORTS, GENERAL, POLITICS, BUSINESS Book Attributes: String title, String authorName, Category category, boolean checkedOut
I have a maths application I am working on in java. This is more related to maths but there could be some here who have worked with calculations like this in their java project.
One could convert from degree to radians and from mph to knots. Could one convert from knots to degree or from mph to degree?
use arrays to store taxpayer information. Use methods for tasks that will be repeated.
-Ask the user how many taxpayers he would like to calculate taxes for. -Ask the user to enter each taxpayer's first name, last name gross income, and number of children. -Each taxpayer's tax due is computed as follows -The taxpayer's dependency exemption is determined by multiplying $3,000 times the number of children. -The taxpayer's net income is determined by taking the taxpayer's gross income and subtracting the taxpayer's dependency exemption. -If the taxpayer's net income is between 0 and 50,000, the tax due is 15% of net income. -If the taxpayer's net income is greater than 50,000, the tax due is -15% of the first 50,000 of net income PLUS -25% of any income over 50,000 -The tax due can never be less than 0. -If the net income is a negative number, the tax due is 0
TAXPAYER INFORMATION: output a message in one dialog box which lists the following info for every taxpayer: first name, last name, gross income, number of children, tax due. AVERAGE TAX: output a message in a dialog box which states the average of the taxes due. PRESIDENTAL MESSAGE: output a message in a dialog box which says either "We computed taxes for the president. " or "We did not compute taxes for the president." The president's name is Barack Obama.
Here is my code so far
import javax.swing.JOptionPane; public class AssignmentSeven { public static void main (String [] args) { String [] taxPayers; String[] firstName; String [] lastName; String message = ""; double[] grossIncome;
I am facing problem during calculation in my awt calculator. It is showing NumberFormatException. Below is part of code.
if(e.getSource()==b14)//On button 14, label is "/" { String v1=tf.getText().toString(); num1=num1+Integer.parseInt(v1);//num1 is as integer variable tf.setText("");//tf means textField }else
how to do this last calculation. I want the user to input and odometer (in feet) and have it use that and the Duration (in hours) to calculate speed in feet per second. Ive been trying to reference it using various methods but I'm stuck. I have it set as a string but whenever i try to pretty much use somewhat the same formula i did for total time it just gives me errors. How do I use that number the user inputs into a formula with the output of the Duration?
* 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. */ package javaapplication1; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Scanner; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane;
I am writing a program in Java where a user adds 1 stamp on a letter for every five sheets of paper in it (or fraction thereof)For example, I if I have 11 sheets of paper, I add 3 stamps. If the total number of stamps is more than 3, they don't send it.
I need to ask the user how many sheets of paper they have, and then calculate the appropriate number of stamps based on the formula above. I just don't know how to write the math formula to calculate this, i'm stuck. So far I have:
package test; import java.util.Scanner; public class LetterMailing { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); int numSheets;
I'm trying to create a GUI interface in Netbeans that calculates a phone bill.
I created a GUI interface that input: - Account Name. - Account Number. - Number of Minutes the phone was used. (with a textarea so the user input the minutes) - 2 JRadioButtoms so the user can chose the regular or premium service. - Amount Due (+10% taxes) (also with a textarea) - Clear/Enter/Result/Done Buttoms
And I need to output: - Account Name. - Account Number. - Number of Minutes. - Taxes - Total Amount Due.
I have a couple of math formulas I have to add them to output the above however I'm new to java so I don't know which code to use.
As stated in the subject I'm a newbie when it comes to Java Programming (I'm in my second week of class). I'm trying to create a Retail Calculator for a class and need to multiply two values together (Price, Discount) in order to get the sale's price when the user hits a Calculate button. The price and discount are user input values from textfields in the beginning of the code.
public void actionPerformed(ActionEvent e) { String price; String discount; float salePrice; //Get the original price from price textfield price = priceValueField.getText();
This may be a multipart question. Basically I have to write a program that accepts a string, converts it to a double splits it and then performs a calculation.
public static void main(String[] args) { String input = ""; // initalize the string boolean isOn = true; // used for the while loop...when false, the program will exit. String exitCommand = "Exit"; // exit command String[] token = input.split(("(?<=[-+*/])|(?=[-+*/])"));
[Code] ....
This is the error I get:
Enter a math problemException in thread "main" java.lang.NumberFormatException: empty String at sun.misc.FloatingDecimal.readJavaFormatString(Floa tingDecimal.java:1842) at sun.misc.FloatingDecimal.parseDouble(FloatingDecim al.java:110) at java.lang.Double.parseDouble(Double.java:538) at Calculator.main(Calculator.java:22)
[Code] .....
How do I go about actually fixing it. Without that line commented out I get this:
Enter a math problem 2+2 <-What I entered [Ljava.lang.String;@135fbaa4
Also, how would I go about using the submethods to check for valid operands and operators (also part of the problem) I have the actual lists made obviously, but am unsure how to get those to work with the problem.
I am new to programming, but am working on a program that takes 6 inputted grade averages on a scale of 0.0 - 100.0 (exceptions in the case someone has exceeded the traditional 100.0 limit) and then divides it by 6 and returns the value in a dialog box. However, I want to take the values inputted and convert them to a 4.0 scale (90.0-100.0 = 4.0, 80.0-89.99 = 3.0, etc.) and then get the average of that so that I can return an average on a 4.0 scale. I have been trying to accomplish. Also, as of right now my program only prompts the user for 6 inputs, but I'd like the user to be able to input as many as he/she would like to, I am pasting the code I currently have below.
import javax.swing.JOptionPane; public class GPA_Calculation1_0 { public static void main(String[] args) { String courseOne = JOptionPane.showInputDialog("Enter numeric GPA of Course One: ");//Course one double numOne = Double.parseDouble(courseOne);
I'm getting this error, I definitely know that is my error trying to pass method/variable because when I commented received part of my code it ran and worked.
I get this error
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
why my session attribute for this banking webapp wont add the deposits to the session var... it just keeps going back to the amount I set it to originally - so if I set the beginning balance to 3000 then deposit 100 it becomes 3100, but if I then try deposit another amount eg. a extra 200 it becomes 3200 not 3300 like it should be !!
I completed this program, everything looks fine as far as calculation and stuff, but the only problem I see is that when the program wants to print the final calculation the formatting is off a little. I will add the ending result at the end of the program.
import java.util.*; import java.text.*; public class FutureValueApp { public static void main(String[] args) {
I am trying to solve this problem but it is not working properly, when i enter the date of birth, such as 1993 12 14 it comes up as 21 years old instead of 20.
import java.util.*; class Age { public static void main( String [] args) { Calendar rightNow = Calendar.getInstance();
My assignment is to make GUI to calculate orders and to save the calculation to .csv file.I have solved "save" button and it really does save my input to .csv file.But, my problem is "Load button" When I press it, how to load .csv file to my existing JTextFields?
So all the errors in the code is fixed but its now got the wrong output
what I get:
Enter numerator; then denominator. 5 8 5/8 Enter numerator; then denominator. 4 10 4/10 Sum:0/0
it should be:
Enter numerator; then denominator. 5 8 5/8 Enter numerator; then denominator. 4 10 4/10 Sum: 82/80 1.025 Product: 20/80 0.25 Enter numerator; then denominator. 6 0 infinity
here is the code
Fraction.java public class Fraction { //declares that it's a class that can be intantiated private int numer; // private intager for numerator private int denom; // private intager for denominator
I need to write a Java program to perform a mathematical calculation between two numbers entered by the user. User has to choose the mathematical operation and input it and then when the user enters 2 numbers, he gets the answer. When user enters any other character other than *, /, + and - he should be able to exit. Perform calculation between numbers should be until user decided to exit from the program. My code is below, calculation part goes well, but can't get it exit when user enter any other character.. How to fix it?
import java.io.*; public class q11 { public static void main(String[]args)throws IOException { InputStreamReader ISR=new InputStreamReader(System.in); BufferedReader BR=new BufferedReader(ISR); while(true){ System.out.println("Enter.."); System.out.println("* : For multiplication");
for (int i = 0; i < letters.length; i++) { double relativeFreq = (onesAverage()/letters[i]); char a = characters.charAt(i); double j = score[i]; System.out.printf();//ToDo
Above is my current code. Basically- There is a string called characters of length 26 (1 char for each letter in alphabet), a double relativeFrequency value which does a calculation and the end result is a number with lots of decimal numbers. The score array has set double values within the array.
What I want to do is create a print f statement where I print out each of the values I initialized above WITH specific amounts of spaces in between. So it should be in this order:
a (spaces) j (spaces) relativeFreq (newLine).
Between J and relativeFreq there should be 4 spaces, however if the value in relativeFreq is greater than 10 (it won't be greater than 100)- then there should be 3 spaces. Everytime I try to create a printf statement my code ends up crooked for some of the values.
for (int i = 0; i < letters.length; i++) { double relativeFreq = (onesAverage()/letters[i]); char a = characters.charAt(i); double j = score[i]; System.out.printf("%c %.4s %.4s%n",a, j, relativeFreq);
I think I fixed the first error, but now I'm receiving another error in my Net Pay print statement at the end.
Here is what I'm supposed to receive:
Net Pay: 599.86
Here is my sample run:
run-single: Enter hourly rate in dollars and cents --> 27.16 Enter number of hours and tenths worked --> 37.9
PAYROLL REPORT Rate: 27.16 Hours: 37.9
Gross Pay: 1029.36 Federal Tax: 257.34 State Tax: 93.41 FICA: 78.75 Net Pay: 771.86
Employer's FICA contribution: 78.75 Employer's UEI and DI contribution: 20.59 Cost to Employer: 1128.70
Enter hourly rate in dollars and cents -->
Here is my updated code:
package assignmentproject1; /* CHANGE (FINAL) VAR NAMES, SCAN & VERIFY, ORGANIZE AND PUT FORMULAS ON BOTTOM, ORGANIZE VAR @ TOP, */ import java.util.*; public class Project1 { public static void main (String[] args)