1,963 Posted Topics
Re: [CODE] String loanAmountString = JOptionPane.showInputDialog("Enter loan amount:"); String loanPeriodString = JOptionPane.showInputDialog("Enter loan period:"); double loanAmount = Double.parseDouble(loanAmountString); int loanPeriod = Double.parseDouble(loanPeriodString); System.out.println("Loan Amount: "+loanAmount); System.out.println("Number of Years: "+loanPeriod); for (rate = 5.0; rate <=8.0; rate=rate + 0.125) { } [/CODE] If you are familiar with exceptions then this would be … | |
Re: [QUOTE=pateldeep454;1166057]Now I have this: [CODE] package captaincrunch; public class Main { public static void main(String[] args) { // TODO code application logic here String alphabet = "abcdefghijklmnopqrstuvwxyz"; char letter; for (int index = 0, size = alphabet.length (); index < size; index++) { letter = alphabet.charAt ((index + 13) % … | |
Re: [QUOTE=Katana24;1158724]Well your suppose to show some of your own work but here's the method for that problem. You will have to create the main method yourself if you want to implement it. [CODE] public static int findMax(int a, int b, int c) { if(a > b && a > c){ … | |
Re: It looks like it should work but have you tested it? Also you will need to take each element of the array and check if it is between 1-12 and 1-31. You should also check depending on the month if it has the irght number of days. (April cannot have … | |
Re: [QUOTE=Ron2794;1164983]i think you have not extended the taxpayer class from other main method class and also the both classes shud be in same package[/QUOTE] You couldn't be more wrong. Please don't give wrong advices if you don't know what you are talking about. Do all Social-Security-Numbers(SSN) need to be like … | |
Re: Since this is your exam it means that you attended a whole semester of your java course. Surely you would know how to create classes with attributes. Well the instructions are pretty clear: [QUOTE] Create a Class ..... EmployeePay (parent) define: attribute: salary(net), gross, rate, no of hours worked, tax=20% … | |
Re: Use BufferedWriter that takes argument a FileWriter. Check their API | |
Re: You need to add an actionlistener to your buttons. Check the api of the JButton and use the addActionListener method. Create a class that implements the ActionListener interface and pass that class as parameter. In that class you will need to implement only one method: [CODE] public void actionPerformed(ActionEvent e) … | |
Re: Create a Class with attributes the line and the last column of the line: [CODE] public class YourClass { private String line = null; private int lastColumn = 0; } [/CODE] Read each line of the file. Use the split method of the String class and take the last "element" … | |
Re: This is a 6-month old thread. It is better if you didn't get your answer here to start a new thread. Also this thread has already enough piece of code to get you started. Start a new Thread with some real questions. People might get the wrong idea with the … | |
Re: Check the String api. There is a method that creates an array of chars. Take the element at the 5th position and increase it by 5. Then use again the String api to find a method (or a constructor) and create a new String out of the char array that … | |
Re: Because 'a' and 'b' don't have the same length: [CODE] for (int i = a.length-1; i >=0; i--){ sum = a[i] + b[i]+ diff; } [/CODE] At the above code you check only if the 'i' will be able to be applied at the 'a' array. But you don't check … | |
Re: I totally agree when you say that we should help only those who try. This is my first post and I would like to mention this incident: I am a professional java programmer and I am registered to another forum for students who do java homework. The reason why I … | |
Re: Actually you call the nextLine, if the previous call was a next() call or a nextInt() call. | |
Re: I haven't read the code, so I don't know what you are doing. But I do know if you want to serialize an object that object, whether you defined the class or it is a java class, must implement the Serializable interface: [CODE] public abstract class Vehicle implements java.io.Serializable { … | |
Re: First of all, it is OK to have multiple tags with the same name, but not the same id. I suggest to change the id of those check boxes. With that way you can use DOM/javascript to modify their state. Check the javascript and DOM tutorials here: [URL="http://www.w3schools.com/default.asp"]http://www.w3schools.com/default.asp[/URL] Also when … | |
Re: loop the array and call the rand.nextInt(3). You use 3 because you said you want 1/3 and 2/3. If the result is 0 then put 'x' in the array. If it is 1 or 2 then put 'b'. Of course the array would be an array of chars | |
Re: Math.random method. Check the api. It returns a random number between 0 and 1: [B][0,1)[/B] | |
Re: Does the Strings s1,s2 have an attribute named: sort ? You can not just imagine methods and attributes and call them. The String object doesn't have such thing: [CODE] s1.[B][COLOR="Red"]sort[/COLOR][/B]; [/CODE] | |
Re: Inside the cases of the do-while you set goOn to false. So you will exit the while-loop: [CODE] .. case 1: myAccount.deposit(); goOn = false; break; .. } while (goOn == true); [/CODE] | |
Re: Does this print: [CODE]System.out.print("Please enter any string: ");[/CODE] It should be printed at the bottom of the screen. Enter input there. The code seems fine. If you run it from command prompt you should be fine. | |
Re: Yes, loop the array and call the Math.pow for each of the elements of the array. From what I see in your code, it is best to create a second array: [CODE] double fx [] = new double[x.length]; [/CODE] While you loop store each result to the new array | |
Re: You haven't defined "reader" also look at the api of the String and StringBuffer class to find the methods you need and ask specific questions. Also you will need a condition to exit the loop. | |
Re: [QUOTE=Sunny89;1160252]u shuld do ur homework urslef atleast 1st try it n move ur lazy ***,[/QUOTE] You are right not to want to do [I]simplyflawless[/I] homework, but your tone doesn't have to be that offensive. Also try to use proper English and not use "bad" language since it is the forum's … | |
Re: Actually I have written a program that times those 2 methods and the String.valueOf() method is much faster than the other: Try this code: [CODE] int N = 1000000; long time = System.currentTimeMillis(); for (int i=0;i<N;i++) { String a = ""+i; } time = System.currentTimeMillis() - time; System.out.println(time); time = … | |
Re: In case you haven't found it: [CODE] String [][] menuInput ={{"File", "Edit", "Windows", "Help"},{"Open","Cut","First","About"},{"Close","Paste","Second", null},{"Exit","Copy",null, null},{null, "Select All", null, null[B][COLOR="Red"],[/COLOR][/B]}}; [/CODE] I think it is the extra ',' you have at the end: {null, "Select All", null, null[B][COLOR="Red"],[/COLOR][/B]} | |
Re: Have you been given a formula for the above calculations because they are not java related and not all people know them, But they can write the code once they are provided. | |
Re: Next time use the button (code) when posting code and put it inside the tags. Question: Have you implemented the java.io.Serializable interface? | |
Re: You have been given the code that does what you want. You have been told the '%' remainder operator: [CODE] if(userNum % 2 == 0 ){ System.out.println("The number "+userNum+" is even"); } else{ System.out.println("The number "+userNum+" is odd"); } [/CODE] The challenge was for you to write the code, not … | |
Re: Why don't you try this simple thing: [CODE] String input = ""; double number = 0.0; boolean goodNumber = false; while (!goodNumber) { input = JOptionPane.showInputDialog(null, USER_LENGTH, null, JOptionPane.QUESTION_MESSAGE); // request length try { input = input.trim(); number = Double.parseDouble(input); goodNumber = true; } catch (NumberFormatException nfe) { goodNumber = … | |
Re: [QUOTE=shah_dolly1985;1157472][code]<% String user=request.getParameter("LedgerName"); ResultSet rs=st.executeQuery("SELECT RoomMasterID,RoomNo FROM RoomMaster AS RM, LedgerMaster AS LM WHERE RM.LedgerID = LM.LedgerID AND LedgerName = '" & Me.datRoomType.SelectedItem.Text & "' AND RM.Status <> 'NO' AND RoomMasterID NOT IN (SELECT DISTINCT RoomMasterID FROM BookingMaster WHERE ' " & Me.datarrivaldate.AmericanDate & " 'BETWEEN FromDate AND ToDate) AND … | |
Re: [QUOTE=nikhilmohan;1156628]i dont want any reply from big peoples lik u... i expected it frm person who willing to help to anybody..[/QUOTE] And what kind of help would you want? Someone to code it for you? What didn't you like from the previous post? It is true that we are not … | |
Re: [QUOTE]Create a product class that holds the item number, the name of the product, the number of units in stock, and the price of each unit.[/QUOTE] [CODE]int dvdNumber[] = new int[arrayLength]; String dvdName[] = new String[] {"Sweet Home Alabama", "How to Loose a Guy in 10 Days", "Ps I love … | |
Re: [QUOTE=Aisha25;1148498]Suppose you save $100 each month into a savings account with the annual interest rate 5%. So, the monthly interest rate is 0.05/12 = 0.00417. After the first month, the value in the account becomes 100 * (1 + 0.00417) = 100.417 After the second month, the value in the … | |
Re: Because you declare it twice: [CODE] [B][COLOR="Red"]String[/COLOR][/B] name do { [B][COLOR="Red"]String[/COLOR][/B] name = ..... ; } [/CODE] You declare it once outside the loop and use it like any other variable: [CODE] String name = "5"; name="asdfasfd"; name += "ssss"; [/CODE] Also you must add a ';' at the end … | |
Re: Scanner class for reading input from keyboard. Search the forum for examples or look the API. Or, use the args[] and enter the values from the command prompt. If statements to check if it is between 0 and 100 and print error message and return. One class will have a … | |
Re: Do you have somewhere the usernames and passwords stored? If yes when the user enters username amd password compare those values with the ones you have saved. | |
Re: I don't believe that the database should be updated. Especially if that column is a Primary Key linked with some other table. For the JTable: When you click the row, you can get the selected row index. That is sequential. When you delete it that value that you have saved … | |
Re: [QUOTE=liaa;1154500]Filename: CommonLetters.java Problem Statement: Write a program that takes two words as input and finds any common letters that they have. For example, the words ‘computer’ and ‘program’ have the letters ‘o’, ‘m’, ‘p’, and ‘r’ in common. The input to the program will be a string which contains two … | |
Re: COMMAND LINE: [QUOTE] > java YourClass arg1 arg2 "arg3 arg4" [/QUOTE] [CODE] public class YourClass { public static void main(String [] [B][COLOR="Red"]args[/COLOR][/B]) { System.out.println("Number of Arguments: "+[B][COLOR="Red"]args[/COLOR][/B].length); for (int i=0;i<[B][COLOR="Red"]args[/COLOR][/B].length;i++) { System.out.println([B][COLOR="Red"]args[/COLOR][/B][i]); } } } [/CODE] The arguments at the command line are passed in the args array. If no … | |
Re: If it throws NullPointerException then something is null. Look at the error message to find the line that this happens. Then try to print the values of the objects used to see what is null. | |
Re: The push method should be: [CODE] if (top == store.length-1) throw new StackException("Stack's underlying storage is overflow"); top++; store[top] = value; [/CODE] Because initially top is -1. The you increase it and use it as index. Meaning that top will hold not the number of elements but the index of … | |
Re: I would suggest to write a method that takes as arguments the array of Students and a Student object: [CODE] boolean static int indexOf(Strudent [] array, Strudent st) { } [/CODE] Loop the array and see if the array contains the Student st. If found, immediately return the index where … | |
Re: 1) You don't initialize the DAO object, you only declare it so it is null. 2) The DAO requires only 1 constructor with no arguments. Because everything that is needed for the opening of the connection are declared inside it. 3) Don't do that: [CODE] dataList.add(rs.getString("zId")); dataList.add(rs.getString("p")); dataList.add(rs.getString("oP")); dataList.add(rs.getString("CSFare")); [/CODE] … | |
Re: The while takes as "argument" a boolean expression. So why don't you use a boolean. At first have it to be true, so you will enter the loop. If the user enters correct String that can be converted into a number, meaning that this: [ICODE]Integer.parseInt[/ICODE] will execute, make that variable … | |
Re: [QUOTE=sincerelibran;1152209][code]public class Person { public String Name; public String SocialSecurityNumber; public String PhoneNumber; public Person(String name, String socialSecurityNumber, String phoneNumber) { Name = name; SocialSecurityNumber = socialSecurityNumber; PhoneNumber = phoneNumber; } @Override public boolean equals(Object compareObj) { if (this == compareObj) // Are they exactly the same instance? return true; … | |
Re: It is because that method doesn't exist (readUTF) when you call it like this: [ICODE]readUTF();[/ICODE] Now if that method was part of another class, like DataInputStream then maybe you should have done this: [CODE] input = new DataInputStream(new FileInputStream("11192007")); acctNum.setText(input.readUTF()); [/CODE] Also check the API for DataInputStream and FileInputStream. If … | |
Re: [QUOTE=stultuske;1151070]we don't deliver custom made code ... I provided you with some logic you could follow, if you know how to create a checkbox and how to work with arrays, you should be able to try that[/QUOTE] He is right. When you run the query save the results in list … | |
Re: [QUOTE=gangsta1903;1151189]your should create your comparator class by implementing Comparator Interface. Once you do it, then you can create your hashtable as follows: [code=java] private Hashtable<String, Planes> planesFlying = new Hashtable<String, Planes>(new YourMapComparator()); [/code] something similar to this.[/QUOTE] [B]That is COMPLETELY [I]gangsta1903[/I] wrong.[/B] If you don't know java don't give wrong … |
The End.