I'm making a program that finds the maximum, minimum, and average values in an integer input ended with a negative number. For example, 4 5 6 -1 is min:4, max:6, and average:5.
It's supposed to handle faulty input in two situations:
1.When an input other than integers is given, the user is given a second chance to give a proper input.
2.When no numbers are given (which is only possible by giving nothing but the negative number end mark), an error message is given because diving by zero integers is impossible.
All the math works fine, but for some reason a proper input in the second chance doesn't. Failing the second chance works, and giving proper input all the way through works. If I fail the first input and then give a proper integer input on the second chance, the program skips over the calculation and gives the divide by zero error. All I could understand from the debugger is that the program is recognizing whatever the first number in that input is, but still keeps the number of numbers as zero (so it's not looping to compare all the numbers in the line either).
import java.util.Scanner; public class FindNumbers implements FindNumbersInterface { double average; double sum; int numberOfNumbers; int total;
[Code] .....
I have a few bits of //old stuff that I've been keeping in case I want to go back.
I am making a program to read data from excel files and store them in tables by their IDs. I have managed to read all the data from excel files as a string and store them in a table. But my project is to store them in table by ascending IDs. I have created the comparator in another class but when i call it in the main class nothing happened. The data that I have to store is like the below:
ID Name Salary 50 christine 2349000 43 paulina 1245874 54 laura 4587894 23 efi 3456457 43 jim 4512878
i want to store and retrieve thumb impression from a database using java.now i am learning java so i want to do the coding using java.i want to know which database is used to store thumb impressions ?
I want to make a database and use it in my java program. I am thinking of using MS Access database, although I m not very sure, sine I will have to use this data later in the SQL database as part of C# program.
How to start to create and use MS database in java program.
I have seen in one tutorial that the steps are:
1. Install your database management system (DBMS) if needed
2.Install a JDBC driver from the vendor of your database
but I am not familiar with this. Any example, or is this above compulsory?
I am trying to write a program and the name variable can only store letters,dotes and spaces. But whenever I enter a space, the program doesn't work. Following is my code.
import java.util.Scanner; import java.util.*; public class Space { public static void main(String []args) { Scanner reader = new Scanner(System.in);
Write a java program to store employee information in a linked list, the program should implement the following functions:
The program should display the list of functions, and ask the user to enter the number of function that he/she wants to do, then perform the function as it is required in the previous table.
import java.util.*; public class Employee { Scanner in = new Scanner(System.in); String Name; String Address; String Department; int ID; int Salary;
[code]....
this is my out put
Please choose a number: 1-Add a new employee 2-Update employee's info 3-Remove employee's info 4-Exit 1 Enter name: Enter address: 2 Enter department: 3 Enter ID: 4 Enter salary:
now:
1- why are not my adding coming out in the output only the Enter name & Enter address ??
2- how can I add names and ID's and information to test that program
I have a textbox called "answer" and 10 different buttons on a form. Now what i would like to do is click the button and have the Button Text in the textbox with the already present text.
So if i click the button 1 it should automatically recognize the clicked button and have its text copied to textbox.
I know the '.get' method but lets say i have 100 buttons so i cant repeat it for every single one of them.
I want to access variable of java file into jsp Page. So I tried to do this but it does not work.
Problem : when I am trying to access "getName" method of java class into jsp file it displaying error, i already imported "Ajaxmethod.java" file in to "success.jsp" I want to access "getName" method in to jsp file without creating object of class.
Ajaxmethod.java package a.b; public class Ajaxmethod implements Action{ public String name; public String getName() { return name; }
I've got a CDI bean which is a facade for a JPA entity. Such entity has got a many to one relationship with itself and I've got the following method:
public Set<Account> getChildren() { return this.children; }
which is called in a JSF/Facelets page:
<h:commandLink action="#{accountController.destroy}" value="#{bundle.ListAccountDestroyLink}" rendered="#{item.children.size() == 0}"/>I then decided to return an unmodifiable set and changed getChildren() accordingly: public Set<Account> getChildren() { return Collections.unmodifiableSet(children); }
The page now reports this error:
java.lang.IllegalAccessException: Class javax.el.BeanELResolver can not access a member of class java.util.Collections$UnmodifiableCollection with modifiers "public" at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65) at java.lang.reflect.Method.invoke(Method.java:588)
[Code] ....
javax.el.BeanELResolver is incorrectly failing because it's trying to invoke the size() method using reflection without correctly taking into account the method visibility (which is indeed invokable programmatically). I'm running NetBeans 6.8, Glassfish 3.0 and jdk1.6.0_17.
I have a doubt about how to design a web application which has their persistent objects in a service layer in a remote server, i mean a business application. So, once we have a web application as a client of this remote business application, how those persistent objects should be mapped in web front?
Should I either pack all jpa annotated classes into the web front application or there is another neat way to do this? I was intending in copy all persistent classes present in the remote business application into the web app package, i know it's not the best way to get what i need.
What is a more appropriate design for a web application which must get some objects from a remote business application and persist some other objects there?
I have a requirement where I have to send a file from a local system to unix box(present on client side) using java code.I have developed a code that is successfully sending the file from local system to client side unix box (I am connecting to client side unix box using VPN) provided I run the code in my eclipse IDE present in local system. But when I am running the same code in the unix box it is throwing null pointer exception.Might be the unix system is not recognising the local system. Please find the code.
I am new to Java programming and how to store data in Java.....Here is a example:Unique number, description, qty in box, price...There are thousands of these in my list. What would be the best way to store them.
I'm doing desktop application about recipes. User can create new recipe, add information. I want to sort recipes, save them somewhere, maybe make it possible to send recipes over network to other users. But I don't know where and how store information about those recipes. I always used to use .txt files for storing needed information, but it seems that it is not the best option.
So I just want to store a Key in a HashMap which can related to two values. For example, the Key "ABC" related to "Fire" which in turn relates to "Heat".
i have two applications running in Glassfish 2, both are using log4j and they have separated log.propeties. The problem is all the log in App2 always store in App1's log file.Here is how i init to load log.properties file.
try { Properties p = new Properties(); p.load(new FileInputStream("C:log.properties1")); org.apache.log4j.PropertyConfigurator.configure(p) ; } catch(Exception e) { e.printStackTrace(); }
Hello World program. We had to build it. Write a basic Java program that will implement one class to store a state of a project. The class should have one property to store a textual name of the state. When a object of this class is created the initial state should be "Open".
1) Class should have one method next() which will move the project to the next step in the sequence: Open - In progress - Closed.If next method is called for a project in the Closed state it should do nothing.
2) Class should have a method close() which will move the project into the Closed state.
3) Class should have a method print() that will output a current state of the project.
Submit a java code file as your assignment. Do not hesitate to contact me if you have any troubles with the assignment.
I have been working on this thing for almost a week, and really don't have a clue on what to do. I know I have to use a string = open, and I know I have to create an object. I don't have a clue on how to do this. I have read the chapter so many times, I almost memorized it, but what he wants is nothing like our demo in the book. the Book used set and get, and utility scanner, but he doesn't want any of that. Just a basic code that will move from Open --- in progress --- closed.
The best I can tell what he wants is when I set the object to open it will display " project is open", then when I set it to " in progress" it will read project is "in progress". I don't have a clue what close is suppose to do, or the print method.
i have a program that is to store DVD information and when i enter all the information asked it returns no info. I have a DVD inventory file and a DVD extended file.
DVDinventoryprogram class package inventory2; import java.util.Scanner;
I was trying to store the content JTextField on char..... Here's the instruction of program--->>create a GUI program that convert letter into corresponding no. EXAMPLE:
if user enter "c" then it will output "3"...... like a=1,b=2,c=3,......
Here's my code
import javax.swing.*; import java.awt.*; import java.awt.event.*; public class convert extends JFrame { private static final int width = 400; private static final int height = 300; private JLabel EN,EQN;