1,963 Posted Topics

Member Avatar for simplyflawless

[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 …

Member Avatar for javaAddict
0
196
Member Avatar for pateldeep454

[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) % …

Member Avatar for pateldeep454
0
902
Member Avatar for Eman1

[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){ …

Member Avatar for Katana24
-1
69
Member Avatar for rue64ja

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 …

Member Avatar for javaAddict
0
75
Member Avatar for musikluver4

[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 …

Member Avatar for javaAddict
0
178
Member Avatar for saphireina

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% …

Member Avatar for saphireina
0
137
Member Avatar for bufospro
Member Avatar for bufospro
1
123
Member Avatar for gabz16

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) …

Member Avatar for gabz16
0
235
Member Avatar for kooldba

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" …

Member Avatar for javaAddict
0
119
Member Avatar for hightech2

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 …

Member Avatar for coderGh
0
1K
Member Avatar for bokoto

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 …

Member Avatar for javaAddict
0
9K
Member Avatar for MaxWildly

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 …

Member Avatar for MaxWildly
0
627
Member Avatar for Dani

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 …

Member Avatar for BestJewSinceJC
5
4K
Member Avatar for skerdzius

Actually you call the nextLine, if the previous call was a next() call or a nextInt() call.

Member Avatar for javaAddict
0
51
Member Avatar for firebugg

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 { …

Member Avatar for javaAddict
0
140
Member Avatar for Santho786

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 …

Member Avatar for selvasoft
0
97
Member Avatar for help_please

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

Member Avatar for javaAddict
0
111
Member Avatar for Sunny89

Math.random method. Check the api. It returns a random number between 0 and 1: [B][0,1)[/B]

Member Avatar for javaAddict
0
72
Member Avatar for akonful

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]

Member Avatar for javaAddict
0
150
Member Avatar for thebluestar

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]

Member Avatar for javaAddict
0
158
Member Avatar for BEBELINDO

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.

Member Avatar for javaAddict
0
188
Member Avatar for mgern26

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

Member Avatar for javaAddict
0
65
Member Avatar for ace22

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.

Member Avatar for ace22
0
92
Member Avatar for simplyflawless

[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 …

Member Avatar for javaAddict
0
432
Member Avatar for darek9576

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 = …

Member Avatar for javaAddict
0
148
Member Avatar for nyny11211

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]}

Member Avatar for nyny11211
0
80
Member Avatar for simplyflawless

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.

Member Avatar for simplyflawless
0
111
Member Avatar for Ciarant

Next time use the button (code) when posting code and put it inside the tags. Question: Have you implemented the java.io.Serializable interface?

Member Avatar for Ciarant
0
196
Member Avatar for memo1

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 …

Member Avatar for javaAddict
0
116
Member Avatar for astronomical

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 = …

Member Avatar for javaAddict
0
137
Member Avatar for shah_dolly1985

[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 …

Member Avatar for javaAddict
0
87
Member Avatar for nikhilmohan

[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 …

Member Avatar for jwenting
0
209
Member Avatar for twgood

[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 …

Member Avatar for Sister_loulou
0
137
Member Avatar for Aisha25

[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 …

Member Avatar for kvass
-1
816
Member Avatar for Dark.Paladin

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 …

Member Avatar for Dark.Paladin
0
156
Member Avatar for blazinhieu

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 …

Member Avatar for stultuske
0
108
Member Avatar for JavaNewbieEK

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.

Member Avatar for javaAddict
0
168
Member Avatar for chandu_517

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 …

Member Avatar for chandu_517
0
196
Member Avatar for liaa

[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 …

Member Avatar for javaAddict
-1
189
Member Avatar for keny2020j
Member Avatar for ilupilu

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 …

Member Avatar for javaAddict
0
83
Member Avatar for rEvOLt

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.

Member Avatar for javaAddict
0
106
Member Avatar for Alex_is

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 …

Member Avatar for jothibasu
0
172
Member Avatar for need

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 …

Member Avatar for Ezzaral
0
174
Member Avatar for Robot1199

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] …

Member Avatar for javaAddict
0
120
Member Avatar for SchoolBoy

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 …

Member Avatar for SchoolBoy
0
84
Member Avatar for Dmith

[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; …

Member Avatar for javaAddict
0
105
Member Avatar for Bemani_lover

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 …

Member Avatar for BestJewSinceJC
0
237
Member Avatar for its.avinash

[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 …

Member Avatar for stultuske
0
93
Member Avatar for beforetheyknew

[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 …

Member Avatar for gangsta1903
0
428

The End.