merxais
04-06-2005, 11:16 AM
what is .equals("") meaning pls? :eek:
|
Click to See Complete Forum and Search --> : Question? merxais 04-06-2005, 11:16 AM what is .equals("") meaning pls? :eek: buntine 04-06-2005, 11:28 AM It is a method that tests the represented values of two strings. It will return true if the calling string object represents (or "holds") the same value as the one which is passed to it. If this case, .equals("") will return true if the calling String object contains an empty string. Regards. merxais 04-06-2005, 01:56 PM import java.text.*; above is apply for? Khalid Ali 04-06-2005, 04:21 PM if you want to develop in Java, start using Java API (http://java.sun.com/j2se/1.4.2/docs/api/index.html) otherwise you will keep asking such questions. Here is a lit of classes, interfaces and exceptions for which java.text.*; applies java.text Interfaces AttributedCharacterIterator CharacterIterator Classes Annotation AttributedCharacterIterator.Attribute AttributedString Bidi BreakIterator ChoiceFormat CollationElementIterator CollationKey Collator DateFormat DateFormat.Field DateFormatSymbols DecimalFormat DecimalFormatSymbols FieldPosition Format Format.Field MessageFormat MessageFormat.Field NumberFormat NumberFormat.Field ParsePosition RuleBasedCollator SimpleDateFormat StringCharacterIterator Exceptions ParseException and one more important advice, never use wildcard imports such as java.text.*; always use explicit imprts for a particular class. such as import java.text.DecimalFormat; merxais 04-07-2005, 06:28 PM i write the following coding but if i want to make it into database... what suppose to do? import javax.swing.*; import java.text.*; public class Project { public static void main(String args[]) //Main { String inputName,inputNameU,inputCont,inputIC,outputName="",outputNameP="",inputReg; //Variable declarations String studentNameU="", inputMore; int inputStudent,inputCourse, loop; double student,fee=0.0,totalFee=0.0,feeTotal=0; DecimalFormat twoDecimals = new DecimalFormat("0.00");//Format used to produce output with 2 decimal points do // do...while loop used to get input from user { inputName=JOptionPane.showInputDialog("Welcome to Dota Tuition Center.\nPlease proceed to view our courses.\n\nPlease enter name for enrol: "); if (inputName==null) //check input validity { JOptionPane.showMessageDialog(null,"Thank you. Program will now exit.", "Program Exit", JOptionPane.WARNING_MESSAGE); System.exit(0); } else if (inputName.equals("")) JOptionPane.showMessageDialog(null,"Please enter your name. Thank you.","ERROR", JOptionPane.ERROR_MESSAGE); }while(inputName.equals(""));//end of do...while loop inputNameU=inputName.toUpperCase();//Changes the input to UpperCase letters //More user inputs: inputCont=JOptionPane.showInputDialog("Please enter your contact number: "); inputIC=JOptionPane.showInputDialog("Please enter your I.C. number: "); inputStudent=Integer.parseInt(JOptionPane.showInputDialog("How many people to enrol?")); for (loop = 2 ; loop <= inputStudent; loop++)//for loop to collect Student's names { inputMore = JOptionPane.showInputDialog("Registration name no."+loop); inputMore = inputMore.toUpperCase(); studentNameU += inputMore +"\n"; }//end of Student for loop do //do...while loop to get user's course { inputCourse=Integer.parseInt(JOptionPane.showInputDialog(null,"Please select course:\n1. English\n2. Mandarin\n3. Malay\n4. Mathematics\n5. Science")); //User input course selection switch (inputCourse)//to get the required information for processing { case 1: outputName+="English"; student=(inputStudent*500.00); fee=student; outputNameP+="15 weeks"; break; case 2: outputName+="Mandarin"; student=(inputStudent*888.88); fee=student; outputNameP+="14 weeks"; break; case 3: outputName+="Malay"; student=(inputStudent*400.00); fee=student; outputNameP+="12 weeks"; break; case 4: outputName+="Mathematics"; student=(inputStudent*999.99); fee=student; outputNameP+="14 weeks"; break; case 5: outputName+="Science"; student=(inputStudent*1200.00); fee=student; outputNameP+="14 weeks"; break; default: JOptionPane.showMessageDialog(null,"Error. Please select from list only. Thank you."); } }while(inputCourse>5 || inputCourse<1);//end of do...while loop feeTotal = countFee(fee);//calling the fee calculation Method totalFee=fee+feeTotal;//calculates the total tuition fees for the course inputReg=JOptionPane.showInputDialog("Enrolment Date: (dd/mm/yyyy)");//asks user to input the enrolment date //prints the output/information: JOptionPane.showMessageDialog(null,"Course: "+outputName+"\nCourse Duration: "+outputNameP+"\nEnrolment Date: "+inputReg+"\n\nStudent(s) issued to:\n"+inputNameU+ "\n"+studentNameU + "\n" +"\nStudent Information:\n"+"Student Name: "+inputNameU+"\nContact number: "+inputCont+ "\nI.C. no: "+inputIC+"\n\nTotal Tuition Fees: RM"+twoDecimals.format(fee)+"\nAdditional Fee: RM "+twoDecimals.format(feeTotal)+ "\nTOTAL Tuition Fees: RM "+twoDecimals.format(totalFee)+"\n\nClick OK to confirm registration."); JOptionPane.showMessageDialog(null,"Your request has been sent. We will call you regarding your payment.\nThank you for choosing Dota Tuition Center.\n\nFor more information or enquiries, please call 03-32918888."); System.exit(0); } //the fee calculation Method: public static double countFee(double price) { double labF,libraryF,insuranceF; //variable declaration labF = 100; // lab fee libraryF = 50; //library fee insuranceF = 0.05; //insurance fee return (labF)+(libraryF)+(price*insuranceF); //returns the total fee amount } }//END OF PROGRAM webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |