How to write logout method

hi
how to write logout method..... i am new to programming
protected void logOut(){
asap

When I posted my first reply, I was thinking of writing to an output log. Do you mean "logout" like in web applications???
You don't need to write any special code for that. At the most, you would want to clean up the resources like connections, sockets,... created by the application. If you have some mechanism which retains some "login" information, you might reset it to some default value.
Why don't you be specific with your question instead of writing in such a vague manner?

Similar Messages

  • How to write the method?

    How do i write the method to generate the following pattern...
    ++++++++++ 1. method name: drawPattern
    -+++++++++ 2. method takes an int as parameter that determines
    --++++++++      the pattern width/height
    ---+++++++ 3. method returns nothing
    ----++++++
    -----+++++
    ------++++
    -------+++
    --------++
    ---------+
    So far i got :
    private static void drawPattern (int width, int height) {
    what else should i include?
    Thanks!

    what else should i include?how about a method body???
    Sorry couldn't resist.
    Big hint: Look at for loops (I did it with 3).
    I would give you my code but this is a homework problem, so my conciousness prevents me from just giving you the solution.
    M

  • How to write a method that takes two arguments of same type

    Hi,
    I seldom do anything "advanced" in generics, but I've done my reading, and thought that I had an understanding of the basics, but I'm stuck on this. How do I write a method that takes two arguments that must be of exact same type.
    I've tried something like:
    public class GenericsTest1 {
        public static <T> void compare(T first, T second) {
    }But the compare method can in this case be called with e.g.
    String arg1 = null;
    Long arg2 = null;
    compare(arg1, arg2);I can restrict the call to something like GenericsTest1.<Long>compare(arg1, arg2), but I don't want to do it in the location that calls the method, and the method can still be invoked with subclasses of the specified type. E.g. this is valid (but I don't want it to be valid):
    Number arg1 = null;
    Long arg2 = null;
    GenericsTest1.<Number>compare(arg1, arg2);So I then changed the method into something like this:
    public class GenericsTest2 {
        public static <T, E extends T> void compare(T first, E second) {
    }It feels like I'm half way there now. Compare can't be called with e.g:
    Long arg1 = null;
    Number arg2 = null;
    compare(arg1, arg2);But this is still valid:
    Number arg1 = null;
    Long arg2 = null;
    compare(arg1, arg2);Hmm... So what to do? I only want the method to be callable when arg1 and arg2 is of exact same type. Everything else should give a compilation error.
    Kaj
    Ps. No, I don't have a need for this, I'm just curious.

    dannyyates wrote:
    I haven't gone through everything you've written, but I would expect that in the first instance, it's inferred <T> to be Object. This is a good reason to parameterise the class rather than the method wherever that makes sense.Thanks for you reply, but as I said this isn't related to anything that I'm going to use. I just want to know if it ca ben done with a static method and generics.
    Kaj

  • How to write a method without knowing how many parameters passed in?

    hi there,
    i m writing a method which is to find out the max value of a set of values, e.g.
       int max(var1, var2, var3, var4) {
          here is the code to find the max value, and return it;
    ......in these case, there are 4 parameters, but what i m trying to do is to write a general method can handle any number of parameters. for some reason, i can't pass in an Array, or a Collection, is there any way i can achieve it?
    thank you!
    best regards

    for some reason, i can't
    pass in an Array, or a CollectionWhy you can't pass a Collection in? I think passing a
    Collection is preferred to the alternative suggestion.and I disagree. Having to build a collection first seems very clumsy. For example, using the following definition of max()
        public static int max(int a, int... b)
            for (int x : b)
                if (x > a)
                    a = x;
            return a;
        }means that I can quite simple get the max of 5 values using
    int max = max(4, a, b,d,21);
    Now you try the same using a collection.
        public static int max(List<Integer> list)
            int max = Integer.MIN_VALUE;
            for (int x : list)
                if (max < x)
                    max = x;
            return max;
    List<Integer> list = new ArrayList();
    list.add(4);
    list.add(a);
    list.add(b);
    list.add(d);
    list.add(21);
    int max = max(list);I know which I prefer.

  • How to write hasCode() & equals(0) methods in Compound Key Class

    Hi Java Helpdesk,
    I am wondering how to write the hashCode() and equals() methods that is mandatory when creating composite
    @IdClass. Below is the combination of primary @Id keys that I would like to make up in a compound key class:
    public final class PatientKey implements java.io.Serializable
        private String firstnameId;
        private String SurnameId;
        private String DateOfBirthID;
        private String Sex;
        public int hashCode()
        public boolean equals(Object otherOb)
    }The Order application in Java EE 5 Tutorial (page 841) is made up of only 2 primary keys.
    Thanks,
    Jack

    Hi,
    Thanks for your very brief response and I had a look at both EqualsBuilder and HashCodeBuilder from the URL links you have provided. These methods may improve the comparison accuracy but I was more interested on how to implement the equals() and hashCode methods when comparing 3 or more primary keys in order to make up a primary key class. Below is my first attempt to compose the PatientPK primary key class:
    1. public class PatientPK implements java.io.Serializable {
    2.
    3.     private String firstName;
    4.     private String lastName;
    5.     private String dateOfBirth;
    6.     private Char sex;
    7.
    8.     public PatientPK() {}
    9.
    10.   public PatientPK(String firstName, String lastName, Date dateOfBirth, Char sex)
    11.   {
    12.       this.firstName = firstName;
    13.       this.lastName = lastName;
    14.       this.dateOfBirth = dateOfBirth;
    15.       this.sex = sex;
    16.   }
    17.
    18.   public String getFirstName() { return this.firstName; }
    19.   public void setFirstName(String firstname) { this.firstName = firstName; }
    20.
    21.   public String getlastName() { return this.lastName; }
    22.   public void setLastname(String lastName) { this.lastName = lastName; }
    23.
    24.   public String getDateOfBirth() { return this.dateOfBirth; }
    25.   public void setDateOfBirth(String dateOfBirth) { this.dateOfBirth = dateOfBirth; }
    26.
    27.   public Char getSex() { return this.sex; }
    28.   public void setSex(String sex) { this.sex = sex; }
    29.
    30.   public boolean equals(Object obj)
    31.   {
    32.       if (obj == this) return true;
    33.       if (!(obj instanceof PatientPK)) return false;
    34.       PatientPK pk = (PatientPK) obj;
    35.       if (!firstName.equals(pk.firstName)) return false;
    36.       if (!lastName.equals(pk.lastName)) return false;
    37.       if (!dateOfBirth.equals(pk.dateOfBirth)) return false;
    38.       if (!sex.equals(pk.sex)) return false;
    39.       return true;
    40.   }
    41.
    42.   public hashCode()
    43.   {
    44.       return firstName.hashCode() + lastName.hashCode() + dateOfBirth.hashCode() + sex.hashCode();
    45.   }
    46.}Please advice whether both these equals() and hashCode() implementations are correct.
    Thanks in advance,
    Jack

  • Can anyone share with me how you  write Javadoc?

    Can anyone share with me how their companies write Javadoc?
    Are your developers solely responsible for it? Do your technical writers own it or review it? How do you make sure it's good?
    Right now, my software developers are mostly responsible for writing all the API info and it's of poor quality and really lacking details. I don't mean spelling/grammar-type problems. My developers just don't seem to "get" what information to include, no matter how many guidelines or checklists I give them.
    A very simple example is:
    * Gets the status
    public java.lang.Integer getStatus() {...}With no indication of what status values may be returned and what the values might mean.
    How do you ensure that what you write is actually useful? Please help!
    I'm aware of the method Sun recommends, but I want to know what others do.
    Thank you

    Hi,
    Well, concerning the question what a good API documentation should be. Just imagine, you are a programmer and you want to use that API. You need to know how it works. There can be only three ways to find it:
    (1) The API documentation
    (2) Probing experiments. Even a good documentation may not describe everything. Sometimes, the only way to understand certain things you particularly need may be guessing something, writing a code basing on it and see how it works. Then, guessing something again, more precisely now, and so on. Even a very good documented API (for instance, javax.swing) may require that sort of approach to be able to use it eventually.
    (3) At last, when source codes are available, one may look at them and try to understand precisely, what a particular method actually does.
    I think the better the API documentation the less one may need to endeavor those two last steps. There is actually a limit about it. Without any proper explanation at all, one may never be able to use a particular API, neither after probing it nor after looking at source codes (that is not to say the sources may be simple unavailable at all).
    Concerning how to write the API documentation, that's mostly the question of managing your team. I think, basically, the original source of the ultimate information about everything implemented in the projects are those very programmers (developers) and, probably, some software architects. But those guys normally are not especially eager to write any documentation (especially developers). That your example just demonstrates it. It seems, your programmers just wrote that "Gets the status" for you to make them leave in rest after that. In addition, the programmers normally have such a sort of work and activity that does not match particularly well with the writing literature and doing their main job simultaneously. You should not enforce them to do that!
    To write a good documentation, you will need to engage a technical writer. That's normally a guy with some programming background. However, writing some literature is actually what he does the best. (Sometimes, such people do something else about written word beyond the technical writing.) The job of that guy would be to write the documentation. This will take from him (or her) two basic things:
    (1) The ability to understand the whole software system (that's where his programming background will be needed!);
    (2) To communicate with the programmers who have developed the stuff and to obtain from them all the necessary information they know. That may require some personal (verbal) communication with them, because asking them to write everything again will only result in the same "Gets the status" explanations. However, to be successful in this, the technical writer needs to have some explicit management approval behind him. Otherwise, some of the guys will avoid speaking to him at all (saying they lack the time). So, the management should assign them the necessary priority for such communications.
    Particularly big projects may even need to have the whole team of technical writers.
    Anyway, writing docs is a hard work. But it is extremely important! The good documentation may both increase your sales and eliminate lots of expense on further support of your customers.
    Regards,
    Leonid Rudy
    http://www.docflex.com

  • How to write an element in a  JTable Cell

    Probably it's a stupid question but I have this problem:
    I have a the necessity to build a JTable in which, when I edit a cell and I push a keyboard button, a new Frame opens to edit the content of the cell.
    But the problem is how to write something in the JTable cell, before setting its model. Because, I know, setCellAT() method of JTree inserts the value in the model and not in the table view. And repainting doesn't function!
    What to do??
    Thanks

    Hi there
    Depending on your table model you should normally change the "cell value" of the tablemodel.
    This could look like:
    JTable table = new JTable();
    TableModel model = table.getModel();
    int rowIndex = 0, columnIndex = 0;
    model.setValueAt("This is a test", rowIndex, columnIndex);
    The tablemodel should then fire an event to the view (i.e. JTable) and the table should be updated.
    Hope this helps you

  • How to write data to an XML file present under application server

    frnds: can ne one tell me, how to write data in to a file, which is present under a application server
    Ex: i want to write a string data in to a file test.txt which is present under "http://localhost:8080/<some_webapp>/test.txt"
    Note:i have deploted a service<some_webapp> under Tomcat/webapps dir

    Very simple. A servlet can writes to that file if it has the good rights.
    In the servlet get (or post) method, use a code like this:
    import java.io.*;
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
    try {
    String filePath = this.getServletContext().getRealPath("/text.txt");//See http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/ServletContext.html#getRealPath(java.lang.String)
             PrintWriter writer = new PrintWriter (filePath);
            //or BufferedWriter out = new BufferedWriter(new FileWriter(filePath));
            writer .println("aString");
           writer.flush();
            writer .close();
        } catch (Exception e) {
           e.printStackTrace();
    }Hope That Helps

  • How to write this assignment in oom way(long)

    i try to write a new class, but i am not very sure if there is only one new class, I shall write a Movie class or a Ticket class?
    this is my Movie class, if I also want to write a new Ticket class. and still i don't know how to write
    because the Ticket class uses some of the attributes of the Movie class such as start time, Movie.name, as in this situation the relation
    between Ticket and Movie is still aggregation, or become a generalization?
    and how to represent that a Movie can have many Tickets? I shall write a buy-ticket method inside the Ticket class or Movie class.
    (are there any thing not right with this movie class? thanks)
    ============================
    class Movie
         String name;
         String startTime;
         String [] coupleChair=new String[11];//start from 1 to 10
         String [] singleChair=new String[11];//start from 1 to 10     
         public Movie(String str1st)
              this.name=str1st;
         public Movie(String str1st, String str2nd)
              this.name=str1st;
              this.startTime=str2nd;
         public String buyA_Single_Ticket()
              int i=1;
              do
                   if(this.singleChair!="sold")
                        this.singleChair[i]="sold";
                        return "You seat is Single Seat No."+i+"\n Enjoy the movie :)";
                   else i++;
              while(i<=10);//when i==11 jump out
              return "Sorry, all Single seats have been sold Out";
         public String buyA_Couple_Ticket()
              int i=1;
              do
                   if(this.coupleChair[i]!="sold")
                        this.coupleChair[i]="sold";
                        return "You seat is Couple Seat No."+i+"\n Enjoy the time ;)";
                   else i++;
              while(i<=10);//when i==11 jump out
              return "Sorry, all Couple seats have been sold Out";
    }//end class
    ============================
    this is the question
    A small ABC cinema has just purchased a computer for its new automated reservations system. You have been asked to program the new system. You are to write a Java application to assign seats on each movie show on the day (capacity: 20 seats for 1 movie).
    Your program should display the following alternatives: ��Please type 1 for couple seat section�� and ��Please type 2 for normal seat section��. If the user types 1, your program should assign one seat in the couple seat section (seats 1 �C 10). If the person types 2, your program should assign a seat in the normal seat (seats 11 �C 20). Your program should also prompt for the movie time and movie name.
    Your program should then display:
    I.     The person��s seat number
    II.     Whether it is a couple seat or normal seat of the cinema
    III.     Time, date, movie name
    Your program should never assign a seat that has already been assigned. When the normal seat section is full, your program should ask the person if it is acceptable to be placed in the couple seat section (and vice versa). If yes, make the appropriate seat assignment. If no, print the message ��Next show is in 3 hours time.��
    (it is just a small test on my OOM learning, I know it is not necessary to make it so complex.)

    Break down your problem into discrete chunks. The more you practice this, the more your initial thoughts will resemble the eventual objects that you will create.
    Let's take address a few of your issues:
    What has the start time? Is it the ticket or the movie? (Hint: Would someone ever print you out a ticket with a different start time than the movie's?)
    If ticket and movie share some attributes, then you can either use inheritance or composition/delegation. In this instance, what makes more sense to you? Is a ticket a movie or vice versa? Or is a ticket simply related to a movie?
    If a given object can contain several instances of another object, you will want to use either an array or a collection, probably List in this instance.
    Why is there no Theater object? A movie may play at multiple theaters. Each theater has a capacity (in terms of total seats and number already booked). This does not really have anything to do with the movie. It is the Theater that you are booking. It may also have which movies are showing at which time.
    Your notion of 'couple' booking seems strange. Why not have a concept like 'consecutive seats required'? That way, your design is more flexible and you can still accomodate couples.That should get you started. Best of luck.
    - Saish

  • How to write the table content of JSP to a file

    Hi there,
    i have a JSP which displays data in table format.
    i need to copy the data of the table( columns with comma separated and rows with line breaks).
    on Mouse click of an hyper link or Button i need to perform the above action.
    as i found java script wont support writing files to hard drive, i expecting help from you guys
    for the solution.
    Thanks and regards
    R

    LoveOpensource wrote:
    Hi thanks for your reply
    i am using struts
    and
    i am displaying the table using
    <logic:iterate can you please tell me how to implement your method on my code
    my complete code for generating the table is
    <table id="tbl" border="1" cellspacing="0" cellpadding="0">
    <tr>
    <td><h4>LPCDealName</h4></td>
    <td><h4>IntexDealName</h4></td>
    </tr>
    <logic:iterate id="rows" property="table" indexId="rowCount" name="LPCIntexActionForm">
    <tr >
         <logic:iterate id="row" indexId="colCount" name="rows" length="2">
    <td><bean:write name="row" /></td>
    </logic:iterate>
    <td><a href="">Modify the Mapping</a></td>
    </tr>
    </logic:iterate>
    </table>
    <% File log = CreateLog(); %>
    //this one for calling method
    //this one for printing data in log file
    <% p.println(LPCDealName);
    p.println(IntexDealName); %>

  • How to write XMP changes back to Photoshop DOM in CS SDK?

    Hello,
    I'm learning to use the ActionScript library for XMP in conjunction with the CS SDK to build Photoshop panels.
    I see from the Extension Builder samples that the AssetFragger application demonstrates how to use XMP for annotating comments to image files in Illustrator using com.adobe.illustrator.  In the runSet() method the XMP data is manipulated then the changes are stored in the document.  So after creating a new XMP node ( XMPArray.newBag() ) it uses doc.XMPString to write the serialized XMP back to the document, then sets doc.saved = false.
            public function runSet():void
                var app:Application = Illustrator.app;
                var doc:Document = app.activeDocument;
                var updateText:String = AssetFraggerModel.getInstance().xmlTextNugget;
                 var xmpString : String = doc.XMPString;
                var xmpMeta : XMPMeta = new XMPMeta(xmpString);
                var ns : Namespace = new Namespace(xmpMeta.getNamespace("xmp"));
                xmpMeta.ns::AssetFraggerDescription = XMPArray.newBag();
                xmpMeta.ns::AssetFraggerDescription[1] = updateText;
                var tmp : String = xmpMeta.serialize();
                doc.XMPString = tmp;   
                doc.saved = false;
    However, using com.adobe.photoshop instead, the XMLString property on the Application activeDocument instance is not available, the doc.saved property is not modifiable (marked as read-only), and the Photoshop Application activeDocument has a xmpMetadata.rawData property available whereas Illustrator did not.  The Photoshop activeDocument.xmpMetadata.rawData is marked as read only, so it can be used to get the plain XMP as a string directly, but once modified the XMP cannot be updated in that property.  Example:
            public static function traceXMP():void
                var app:Application = Photoshop.app;
                var doc:Document = app.activeDocument;
                var xmpString:String = doc.xmpMetadata.rawData;
                var xmpMeta:XMPMeta = new XMPMeta(xmpString);
                var metaXML:XML = xmpMeta.serializeToXML();
                var Iptc4xmpCore:Namespace = new Namespace(XMPConst.Iptc4xmpCore);
                // demonstrate that a leaf in IPTC can be changed and written to the trace console
                xmpMeta.Iptc4xmpCore::CreatorContactInfo.Iptc4xmpCore::CiUrlWork = 'http://test.com/';
                trace(ObjectUtil.toString(xmpMeta.Iptc4xmpCore::CreatorContactInfo.Iptc4xmpCore::CiUrlWor k.toString()));
                // but now how to write the XMP change back to the Photoshop DOM?
    My question is, for a given image file exported as from Lightroom that is rich in custom IPTC metadata, how does one update the metadata in Photosohp via XMP and the CS SDK?  I was not able to extract this information from the Advanced Topics: Working with XMP Metadata chapter of the CS SDK documentation
    A real, and complete code example would be greatly appreciated over a pseudocode example.
    Thank you in advance.
    Steven Erat

    Ah ha.  Found the problem, thanks to Ian.  When I saw the inline help appear in Extension Builder for app.activeDocument.xmpMetadata, it indicated that the node as [Read Only], however, the leaf app.activeDocument.xmpMetadata.rawData is in fact not read only. I incorrectly assumed rawData was not writeable when in fact it is.

  • How to write ABAP HR reports in ABAP web dynapro

    Hi All,
    How  to write ABAP HR reports in ABAP web dynapro? We can add HR REPORT CATEGORY in ABAP HR using logical database like PNP.How to add HR REPORT CATEGORY in ABAP Webdynapro ?
    Thanks.

    You can't use legacy concepts like logical databases directly in Web Dynpro ABAP.  Even if you could do so, you shouldn't.  Web Dynpro ABAP should always follow MVC - meaning that your business logic (the model) should be separated from WD as much as possible. This means calling function modules or class methods to consume the business logic and data.  So in general there should be no difference between building HR reports or any other type of report in WDA - since from the WDA side you are calling other objects to consume the data. 
    This probably does mean that you will need to create classes to expose the HR data that you want in your WDA.

  • How to call a Method in a Program?

    Hello,
    I am very new to the ABAP world.  I have been given a task to call a method if_hrbas_plain_infotype_access~read_single from the class CL_HRBAS_PLAIN_INFOTYPE_ACCESS in a program to see if we can use it to display some employee information.  I don't know how to call a method in a program.  Can somebody please provide me some pseudo code or instructions?
    Thanks.

    Hi Shan,
    here is the code to call a method. while calling the method Instance as 'r_info' which is the type reference to class as specified.
    pass the values to exporting parameters plvar,otype,objid...etc  according  to the requirement
    infotypes: 0002.   " creates an internal table p0002.
    data:
    r_info type ref to CL_HRBAS_PLAIN_INFOTYPE_ACCESS.
    TRY.
    CALL METHOD r_info->if_hrbas_plain_infotype_access~read
       EXPORTING
         plvar           = 
         otype           =
         objid           =
         istat           =
         infty           =
    *     SUBTY           =
         begda           =
         endda           =
         no_auth_check   =  'X'
         message_handler =
       IMPORTING
         PNNNN_TAB       = P0002
    *     HRTNNNN_TAB     =
    *     IS_OK           =
      CATCH CX_HRBAS_VIOLATED_ASSERTION .
    ENDTRY.
    LOOP AT P0002.
          WRITE:/
            P0002-VORNA,
            P0002-NCHMC,
            P0002-NACHN.
        ENDLOOP.
    Regards

  • Really need help on how to write this program some 1 plz help me out here.

    i am new to java and i confused on how to be writing this program.
    i have completed the Part 1 but i am stuck on Part 2 & 3 so it would would be really great if any 1 could help me out on how to write the program.
    Part I
    An algorithm describes how a problem is solved in terms of the actions to be executed, and it specifies the order in which the actions should be executed. An algorithm must be detailed enough so that you can "walk" through the algorithm with test data. This means the algorithm must include all the necessary calculations.
    Here is an algorithm that calculates the cost of a rectangular window. The
    total cost of a window is based on two prices; the cost of the glass plus the cost of the metal frame around the glass. The glass is 50 cents per
    square inch (area) and the metal frame is 75 cents per inch (perimeter).
    The length and width of the window will be entered by the user. The
    output of the program should be the length and width (entered by the user)
    and the total cost of the window.
    FORMULAS:
    area = length times width perimeter = 2 times (length plus width)
    Here is the corresponding algorithm:
    read in the length of the window in inches
    read in the width of the window in inches
    compute the area
    compute the cost of the glass (area times 50 cents)
    compute the perimeter
    compute the cost of the frame (perimeter times 75 cents)
    compute the total cost of the window (cost of glass plus cost of frame)
    display the length, width and total cost
    The next step would be to "desk check" the algorithm. First you would need to make up the "test data". For this algorithm, the test data would involve making up a length and a width, and then calculating the cost of the window based on those values. The results are computing by hand or using a calculator. The results of your test data are always calculated before translating your algorithm into a programming language. Here is an example of the test data for the problem given:
    length = 10
    width = 20
    area = 200, glass cost= 100.00 (area times 50 cents)
    perimeter = 60, frame cost = 45.00 (perimeter times 75 cents)
    total cost =145.00
    Once the test data is chosen, you should "walk" through the algorithm using the test data to see if the algorithm produces the same answers that you obtained from your calculations.
    If the results are the same, then you would begin translating your algorithm into a programming language. If the results are not the same, then you would attempt to find out what part of the algorithm is incorrect and correct it. It is also
    necessary to re-check your hand calculations.
    Each time you revise your algorithm, you should walk through it with your test data again. You keep revising your algorithm until it produces the same answers as your test data.
    ?Now write and submit a Java program that will calculate the cost of a rectangular window according to the algorithm explained. Be sure to prompt for input and label your output.?
    Part II
    Write, compile and execute a Java program that displays the following prompts:
    Enter an integer.
    Enter a second integer
    Enter a third integer.
    Enter a fourth integer.
    After each prompt is displayed, your program should use the nextint method of the Scanner class to accept a number from the keyboard for the displayed
    prompt. After the fourth integer has been entered, your program should calculate and display the average of the four integers and the value of the first integer entered raised to the power of the second integer entered. The average and result of raising to a power should be included in an appropriate messages
    (labels).
    Sample Test Data:
    Set 1: 100 100 100 100
    Set 2: 100 0 100 0
    Be sure to write an algorithm first before attempting to write the Java code. Walk through your algorithm with test data to be sure it works as anticipated.
    Part III
    Repeat Part lI but only calculate the average, not the power. This time, make sure to use the same variable name, number, for each of the four numbers input. Also use the variable sum for the sum of the numbers. (Hint: To do this, you may use the statement sum = sum + number after each number is read.)
    For Part 1 this is what i got
    import java.util.Scanner;
    public class Window
         public static void main(String[] args)
              double length, width, glass_cost, perimeter, frame_cost, area, total;
              Scanner keyboard = new Scanner (System.in);
              System.out.println("Enter the length of the window in inches");
              length = keyboard.nextInt();
              System.out.println("Enter the width of the window in inches");
              width = keyboard.nextInt();
              area = length * width;
              glass_cost = area * .5;
              perimeter = 2 * (length + width);
              frame_cost = perimeter * .75;
              total = glass_cost + frame_cost;
                   System.out.println("The Length of the window is " + length + "inches");
                   System.out.println("The Width of the window is " + length + "inches");
                   System.out.println("The total cost of the window is $ " + total);
         Enter the length of the window in inches
         5
         Enter the width of the window in inches
         8
         The Length of the window is 5.0inches
         The Width of the window is 5.0inches
         The total cost of the window is $ 39.5
    Press any key to continue . . .
    Edited by: Adhi on Feb 24, 2008 10:33 AM

    Adhi wrote:
    i am new to java and i confused on how to be writing this program.
    i have completed the Part 1 but i am stuck on Part 2 & 3 so it would would be really great if any 1 could help me out on how to write the program.Looks like homework to me.
    What have you written so far? Post it.
    Part I
    An algorithm describes how a problem is solved in terms of the actions to be executed, and it specifies the order in which the actions should be executed. An algorithm must be detailed enough so that you can "walk" through the algorithm with test data. This means the algorithm must include all the necessary calculations.
    Here is an algorithm that calculates the cost of a rectangular window. The
    total cost of a window is based on two prices; the cost of the glass plus the cost of the metal frame around the glass. The glass is 50 cents per
    square inch (area) and the metal frame is 75 cents per inch (perimeter).
    The length and width of the window will be entered by the user. The
    output of the program should be the length and width (entered by the user)
    and the total cost of the window.
    FORMULAS:
    area = length times width perimeter = 2 times (length plus width)
    Here is the corresponding algorithm:
    read in the length of the window in inches
    read in the width of the window in inches
    compute the area
    compute the cost of the glass (area times 50 cents)
    compute the perimeter
    compute the cost of the frame (perimeter times 75 cents)
    compute the total cost of the window (cost of glass plus cost of frame)
    display the length, width and total cost
    The next step would be to "desk check" the algorithm. First you would need to make up the "test data". For this algorithm, the test data would involve making up a length and a width, and then calculating the cost of the window based on those values. The results are computing by hand or using a calculator. The results of your test data are always calculated before translating your algorithm into a programming language. Here is an example of the test data for the problem given:
    length = 10
    width = 20
    area = 200, glass cost= 100.00 (area times 50 cents)
    perimeter = 60, frame cost = 45.00 (perimeter times 75 cents)
    total cost =145.00
    Once the test data is chosen, you should "walk" through the algorithm using the test data to see if the algorithm produces the same answers that you obtained from your calculations.
    If the results are the same, then you would begin translating your algorithm into a programming language. If the results are not the same, then you would attempt to find out what part of the algorithm is incorrect and correct it. It is also
    necessary to re-check your hand calculations.
    Each time you revise your algorithm, you should walk through it with your test data again. You keep revising your algorithm until it produces the same answers as your test data.
    &#147;Now write and submit a Java program that will calculate the cost of a rectangular window according to the algorithm explained. Be sure to prompt for input and label your output.&#148;
    Part II
    Write, compile and execute a Java program that displays the following prompts:
    Enter an integer.
    Enter a second integer
    Enter a third integer.
    Enter a fourth integer.
    After each prompt is displayed, your program should use the nextint method of the Scanner class to accept a number from the keyboard for the displayed
    prompt. After the fourth integer has been entered, your program should calculate and display the average of the four integers and the value of the first integer entered raised to the power of the second integer entered. The average and result of raising to a power should be included in an appropriate messages
    (labels).
    Sample Test Data:
    Set 1: 100 100 100 100
    Set 2: 100 0 100 0
    Be sure to write an algorithm first before attempting to write the Java code. Walk through your algorithm with test data to be sure it works as anticipated.So this is where you actually have to do something. My guess is that you've done nothing so far.
    Part III
    Repeat Part lI but only calculate the average, not the power. This time, make sure to use the same variable name, number, for each of the four numbers input. Also use the variable sum for the sum of the numbers. (Hint: To do this, you may use the statement sum = sum + number after each number is read.)Man, this specification writes itself. Sit down and start coding.
    One bit of advice: Nobody here takes kindly to lazy, stupid students who are just trying to con somebody into doing their homework for them. If that's you, better have your asbestos underpants on.
    %

  • How to write and what is the G/L Distribution Report (AP)?

    Hi all,
    I am anticipating  to write some abap reports..Here is one of them..Anyone can help  me with writing a Report , how to write 'G/L Distribution Report (AP) -
    But since I am new to Abap , if you wish to reply, please use a little more detail and simple explanation, step by step so I can understand what is the idea(The Business use, and business idea of doing such report?), how it can be acheived...what kind of report should be used , techniques, tables etc..?.:)
    Appreciate your help!
    Regards,
    Boby

    Hi   ,
    i am get your  exact   report requirements  , nay   , i will give you the   brief expalin.
    AP -> Accoutns  Payable   . so it deals with  in Finnance to  Vendor  .   it means   you are   maintain the  transcations  of the payment s to the vendor .  so thae  table's are .
    vendor master tables  : 
    LFA1 -> Vendor Master (General Section),
    ADRC -> Addresses (Business Address Services)
    LFB1-> Vendor Master (Company Code) ....etc .
    for finance   data  
    BKPF -> Accounting Document Header
    BSEG->Accounting Document Segment
    BSIS->Accounting: Secondary Index for G/L Accounts
    PAYR->Payment Medium File
    WITH_ITEM->Witholding tax info per W/tax type and FI line item ,
    REGUP-> Processed items from payment program ,
    REGUH-> Settlement data from payment program  ,....etc
    with  abouve  given  table you can  do the report  for  vendor   .
    Start  selecting data from the bseg   , because  it will have  all the  data ...... then if  it is  payement    , then  go to the  regup   for  processed  item  ..... it means  payment happpend data   .........  then go to reguh   for  the   payment method  (check, draft ,etc)  then to the payr for check data.etc  .... if you want  vedor   address  go to   lfa1 there  ADRNR  is there primary key to adrc table  for   detail addresss..
    if it  is use full  , reward  points ...........
    Girish

Maybe you are looking for

  • Opening multiple databases in a single file

         Hello everybody, I need create 1000 small databases(tables) in a single physical file, how to solve? ( I have read chap 3 Access Method Operations in BDB programmer reference,  so I know it's need create a shared database environment, but I don'

  • Airplay/Airtunes menus not showing up on iphone 4 v4.3.3

    I upgraded my windows iphone to v 4.3.3 so I could utilize airplay/airtunes.  It worked at first, albeit intermittently, the first day.  Now I can't see the menu anymore.  For what it's worth, airtunes works just fine streaming from my laptop through

  • Configuring Mail 3.2 and Exchange

    I have searched the discussions here but have not been able to solve my problem: I am trying to set up Mail so that it syncs with a new Exchange mailbox I have. But, I can't find detailed information on how to set up the account in Mail given the inf

  • How would i design the relationship between "question", "subquestion", and "answer"

    Hi all. Consider the following scenario: Scenario: A Question has an Answer, but some Questions have Subquestions. For example: 1. Define the following terms: (Question) a) Object (1 marks) (Subquestion) An instance of a class. (Answer) b) ... 2. Dif

  • Error when checking email adress for imessage activation

    Hi, i am french so, first, sorry for the many mistakes i'm gonna do in english ^^ I have a problem with imessage and facetime activation on my Ipod touch 4G (IOS 6.1.1) When taping my email adress and apple password there's no problem, i can access t