I am writing a program to store books (Book class) in volumes (Volume class). Within the main class (DemoVolume) I am doing a couple different things. I want to ask the user if they are creating a new array, if yes, I was to create a new array with a variable names assigned by the user. Is this possible? The reason is I want to allow the user to be able to search their library of volumes. If no, then the user will enter the book information and I will assign it to an array unassignedVolume that will contain individual books. I would also like to create book objects that are defined with the book name, if this is possible. I'm just messing around and trying to deepen my understanding of JAVA. My main issue is how to allow the user to title the volume (array variable).
import java.util.Scanner; public class DemoVolume { public static void main(String[] args) { Scanner input = new Scanner(System.in); String [] volume, unassignedVolume; Volume volumeOne = new Volume("JAVA", 3, volume);
i am to add jpanels to an arraylist such that it forms a grid like a 2d array. when i add the first colunm and have to iterate and store the next sequence of jpanels it still stores it in get(0), instead of get(1).
import java.util.Scanner; public class Exercise1{ public static void main(String[] args) { String employeeName, employeeNumber, position, department ; double otpay, salary, deduction, hrs, rate ; Scanner input = new Scanner (System.in);
[Code] ....
That's my codes but its wrong according to our prof. it should be in frame form. i don't know how to do it since i did not encountered framing since i was started in java.
I have a form containing several fields, 2 of which persist to different table in a database than the rest of the fields on the form. I have no problem persisting the data into both tables of the database, and after the form is submitted I reset the form to its default values. That all works fine.
But in the same session, when I open another form (a search form) and enter search criteria, which then displays a datatable containing the search results, those 2 values that are persisted to another table are not showing up, but the rest of the data is.
Here is the method that calls the persist methods:
@ManagedBean(name = "foreignPartyController") @SessionScoped public class ForeignPartyController implements Serializable { ... public void saveData() {
[Code].....
The values do show up, but the problem is, when a subsequent form is opened in the same session (e.g. a search form) the field for that value shows the actual value, instead of the field being blank.'
I am not sure why the data from the one database ("parent") is showing up, yet the data from the other database ("child") is not.
Is it something I am doing wrong? I thought by setting the setter in the child controller class back to a new instance of the Entity class (PolicyPayment) that it would reset the form to default values, but at the same time retain (or save) the inputted values in the same session.
I have a button on UI which adds messages and when the user clicks on it the form gets submitted, meanwhile the user is clicking on refresh(F5) multiple times which is causing the same message to be displayed multiple times. To resolve this , I am converting the form from a synchronous submit to Asychronous but it is still not working. Below is the code:
this is my program error occured run time,but compile sucessfully
{error msg-Error: Main method not found in class helloworldapp.HelloWorldApp, please define the main method as: public static void main(String[] args)} class HelloWorldApp { private int empno; private float salary; void setHelloWorldApp() { empno=12; salary=1200;
I want to create a JTable which "Analysis","Date" and "Price" the names of columns in header. Here's a piece of my code :
String sql = "Select name, Price from analysis_tab where name ='" + idclicked + "'"; DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); Date date = new Date(); PreparedStatement preparestate = database.con.prepareStatement(sql); ResultSet rs = preparestate.executeQuery();
So, the value of Analysis and Price were stored in my Data Base, and the Date get the value of the current day. How can i create this JTable and how can i set the value into it ?
I am new to Java and i am doing an assignment to identify Class and Attributes from below example. identify 7 classes and its attributes from this scenario:
ABC Maps Maker produces electronic maps for global positioning systems. Every map needs to define the latitude and longitude of the centre of the map, together with the length and breadth of the map. A map also has a name, and a set of geographical features.
A geographical feature is something noticeable in a a map; e.g., a hill, or valley. Among the types of features are the following: trace features, track features and tract features. All features have a name that is displayed on the map next to the feature.
A trace feature has a coordinate point to indicate its location relative to the centre of the map.
Broadcasting stations, mountain peaks, and transmission towers, are examples of trace features. Every trace feature has a description associated with it. Examples of track features include roads, railways and rivers. Each track feature has a list of points that define its course, and a line pattern. The line pattern specifies the colour, and the thickness.
Like a track feature, a tract feature also has set of points, except that when drawn on the map, the last point is linked to the first point to enclose a complete region. Additionally, it has a fill pattern which incorporates essentially a colour. Recall that there is a class, Point, in the java.awt package - this can be used to hold the co-ordinate of a point
I am working on a problem where i have to create a 2d array with given input of the dimensions (odd number) of array, along with a number within the array and to then print out all of the numbers surrounding that number.
Anyway, i am working on simply making the spiral, which should look like the one below.
n = 3
7 8 9 6 1 2 5 4 3
where the 1 always starts in the center with the 2 going to the right, 3 down, then left etc. etc. I was able to create the code by starting on the outer edges rather than the center and working my way to the middle, however my code always starts from the top left and goes around to the center where it needs to start from the top right. I am having trouble altering my code to meet this criteria. This is what i have thus far.
import java.io.*; public class Spiral { public static void main(String args[])throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter the number of elements : "); int n=Integer.parseInt(br.readLine());
I am passing input from the user to a method that will initialize an array of the data (scores in this case). The method is filling the entire array with the last input value.
array initializer method
Java Code:
public static float[] inputAllScores(float validScore) { float[] diverScores = new float[7]; for (int i = 0; i < diverScores.length; i++) { diverScores[i] = validScore; } return diverScores; } mh_sh_highlight_all('java');
I'm trying to make a simple table with JTable class by reading the following tutorial but when try to see my JTable my program doesn't show me nothing! What i'm doing wrong?
[Code] .....
import javax.swing.JScrollPane; import javax.swing.JTable; public class MyFirstTable { public static void main( String[] args ) { String[] columnNames = {"First Name", "Last Name",
I don't understand how i'm supposed to define a variable when the user has to type it into the program so it can be converted. This program i'm working on is supposed to convert from meters to feet (meter = feet * 0.305) but the user has to type in the meters they want converted. how do i solve the problem that keeps coming up that says "variable meter symbol cant be found" ? I keep trying different lines to no avail
public class Lab2 { public static void main(String[] args) { double feet = meter * 0.305; double meter = feet/0.305; System.out.println("Enter in feet for conversion to meters"); meter = meter * 0.305;
Create a one dimensional array which holds 10 values. Ask the user to input an index value between 0 and 9. Print the value the user selected. Be sure to explain the output to the user. That is my assignment, and here is my code:
import java.util.Scanner; public class Array { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int a[]= new int[9]; a[0] = 10; a[1] = 20;
[code]....
I don't know how to use the scanner to get someone's input properly.
I need to process one component drag to the table. I misunderstand, how I can see to which Cell fall the component. I tried to use Event and Mouse event handlers in my custom Cell, but they do not work. I can copy the drag event to the table and table handles it, but how to get needed Cell I cant understand.
I have this very simple application just to test console input:
import java.util.ArrayList; import java.util.Scanner; public class WriteTester {
[Code]....
When I let it run, only every third entry is put into the array list and I have to hit "enter" three times for the "break" in line 21 to trigger. I cannot find out why.
I am having trouble with an assignment. I need the user to input the size of the array and print when asked. In my program, it prints 100 numbers instead of the user input number, such as 15.
import java.util.Arrays; import java.util.Scanner; import java.util.Random; public class Lab9 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int [] values = new int [100];
I am trying to do a simple noughts and crosses game. I have displayed a board using a 2 dimensional array and display it using a for loop. The array is of type int. What I want to do is allow the user to choose a specific cell within the array to change to an x or o but I am not sure how to go about doing this. I have seen lots of examples of noughts and crosses online but seem to all be examples of how to check a win or lose situation.how to allow a user to choose certain cells in a 2d array would be great.
Creating an array searcher wherein it all depends on the user input. On the first user input it would be the array to search from while the second input would be something to be searched for inside the loop?
OK! I have a declared and populated string array containing final tennis scores i.e.{"love", "15", "30", "40", "game"}.The user has already entered the score as integers 0,1,2,3,4. I need to design a method in a set get class to use the score input in the main class to display the final score in the main.here's what I got:
import java.util.*; public class DemoTennisGame { public static void main(String[] args) { String player1; String player2; int score1; int score2;