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.
“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.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.
%

Similar Messages

  • I do not know how to get the music that I buy on itunes, on my mac, onto an ipod. I have already authorized my computer and "downloaded" my music, but that did not do anything. Please I really need to know how to do this on my own but I am stuck.Thank you

    I do not know how to get the music that I buy on itunes, on my mac, onto an ipod. I have already authorized my computer and "downloaded" my music, but that did not do anything, or provid the results that I was expecting, at least. Please, I really need to know how to do this on my own but I do not know what to do.Thank you in advance to anyone that is answering this question that I know most everyone but me knows how to accomplish. thanks!!!

    In iTunes go to the Help menu in the upper menu bar.  Then click on iTunes Help. Then on Sync your iPod, iPhone or iPad and follow the instructions.

  • How to write this application - URGENT PLEASE HELP

    I would like to write a program for a supermarket loyalty card system. The program should have 2 customers and 2 gifts on offer. The customer details and the gift details can be hard coded.
    When the program starts the user should be shown a menu which will have options to
    view all customer details
    add points for a customer
    buy a gift
    When the user chooses to buy a gift ro to add points, any changes made to the customers' points must be done using methods. Adding or buying gifts should be done using customer id's and gift id's.
    The user must be able to see the altered points.
    I WILL APPRECIATE IF I COULD GET HELP EVEN FOR PSEUDOCODE.

    Not as much as this guy tho http://forum.java.sun.com/thread.jsp?forum=31&thread=486327&tstart=150&trange=15

  • Help me:how to write this query

    i have a table employees,the data is :
    LAST_NAME DEP SALARY HIRE_DATE COMMISSION_PCT
    gets 10 4000 20060101000000
    davis 20 1500 20060303000000
    king 20 4000 20051118000000
    gets 30 5000 20040101000000
    kochhar 5000 20051201000000
    higens 40 3500 20050706000000
    my question is :
    create a query that will display the toatl number of employees and ,the number of employees hired in 2004,2005,2006.as follow:
    total 2004 2005 2006
    6 1 3 2
    thanks a lot.

    This might help you
    SQL> select * from emp;
    LAST_NAME         DEP     SALARY           HIRE_DATE COMMISSION_PCT
    gets               10       4000      20060101000000
    davis              20       1500      20060303000000
    king               20       4000      20051118000000
    gets               30       5000      20040101000000
    kochhar            30       5000      20051201000000
    higens             40       3500      20050706000000
    6 rows selected.
    SQL> SELECT COUNT(1),SUM(DECODE(SUBSTR(HIRE_DATE,1,4),2004,1,0)) "2004",
      2                  SUM(DECODE(SUBSTR(HIRE_DATE,1,4),2005,1,0)) "2005",
      3                  SUM(DECODE(SUBSTR(HIRE_DATE,1,4),2006,1,0)) "2006"
      4  FROM EMP
      5  /
      COUNT(1)       2004       2005       2006
             6          1          3          2
    SQL>Regards,
    Mohana
    I didn't see Jameel's and APC's solution. They are faster than me :)
    Message was edited by:
    Mohana Kumari

  • How to write this program

    I got one output list .
    In that If I  modify any contents in that output list that will directly affect to the data base contents and replace these contents.
    Please provide  some solution how we can update.

    Some ideas on how to implement the problem that you have.
    Server :
    1. Let the server listen to requests from various clients to join the game.
    2. On receiving a request from a client to play the game add him into a circular list where last node point to the first (Don't forget to hold pointers to first and last nodes ;) ) And each node can store al the details of each client like his host ip, his previous letters and answers, his current score et
    3. Create another thread on the server which picks a client from the circular-list and sends him a letter and wait for that particular client to respond. On getting a response from the client, process the word, give him the score and move on to the next node on the circular list. By doing this a round-robin order can be achieved.
    Note: Sleep isn't of much use on the server as the server has to be awake always expecting requests and responses from the clients.
    Client :
    1. Client can be a thread which connects to server and initial sends a request to join the game and waits for response from the sever which will be the "Letter" with which the client will build a word and sent it back to server and goes to sleep until it gets a response from the server which will be the next letter and current score etc
    2. Client and server have to agree to a protocol so that they can understand each others responses.
    3. If you do not have a network to test this then you can create multiple instances of the client on the same machine and connect all these instances to the server.

  • [SOLVE] How to install this program (PyIpChanger)?

    Hello!
    I'm new to the forum and I wanted you to help me how to install this program.
    https://otland.net/threads/pyipchanger- … ts.157953/
    It is a ip changer for Tibia, to play in OT servers.
    Since there does not exist in the official repositories nor in the AUR, It is necessary install manually, but I can't figure out
    *Sorry my english, I'm not a native speaker.
    Best wishes!
    Last edited by Rearis (2015-05-10 14:52:48)

    Robg told you how to do this:
    robg wrote:
    Just use pacman to install: pyhon2, python2-pyqt4
    After having done that, you can run main.py using pyhon2.
    So install the software, then run:
    python2 PyIpChanger.py
    Last edited by mrunion (2015-05-07 13:36:31)

  • I am setting up a new iMac and need help syncing files to Dropbox.  On my old computer I had it set where when I saved a document, it was saved on my hard drive, as well as to a folder in Dropbox.  I can't remember how I set this up.  Any help?

    I am setting up a new iMac and need help syncing files to Dropbox.  On my old computer I had it set where when I saved a document, it was saved on my hard drive, as well as to a folder in Dropbox.  I can't remember how I set this up.  Any help?

    The way that Dropbox works is that it keeps a copy of all your files in your local Dropbox folder on your hard drive (which is, by default, directly under your home folder). Adding files to that folder will sync them to the Dropbox server.
    You do of course have to download the Dropbox application to enable this (download link at the top right of http://dropbox.com ).
    Matt

  • I bought CS6 creative suite. As of now i need to work each application in separate separate system. Can any one please help me how to solve this problem.

    I bought CS6 creative suite. As of now i need to work each application in separate separate system. Can any one please help me how to solve this problem.
    I saw the below quote on Adobe forum
    "You may install software on up to two computers. These two computers can be Windows, Mac OS, or one each."
    If i install each application in single single system the system count is more than two. In this case, are we have any license issue? Please advice how the problem will solve?
    If possible please send the advise to my mail id: <Removed by Moderator>
    Thanks
    Uvaraj S

    I already answered that.  If you purchased a Suite then you can only install and activate it on two machines.  Even if you only insdtall one of the applications of that suite, it counts as one activation of the suite.  You cannot take the six or seven different applications that might be in a suite and install and activate them in six or seven different machines... only two machines.
    If your scenario will allow for it, one thing you can do is install the programs on all the different machines and only activate two of the machines at any given time.  If you need to activate a program on a third machine then you need to deactivate on one of the currently activate machines first so that you have an open activation to use again.  I do not remember if there is a limit to the total number of activations you can process for the life of the software.

  • I was told I need to remove the enterprise server account I have and need to add a new one for work but the IT person did not tell me how to do this.  Can anyone help?

    I was told I need to remove the enterprise server account I have and need to add a new one for work but the IT person did not tell me how to do this.  Can anyone help?

        Jennymbell, never fear help is here!
    Have you tried contacting your IT department for assistance? You can visit http://bit.ly/QECbGh for steps on how to enterprise activation.
    Keep me posted if you need further assistance.
    John B
    Follow us on Twitter @VZWSupport

  • I am trying to update the new settings on my iphone 4s but every time I plug in to update it tells me i need to change my media sync options and I'm unsure how to do this? Can anyone help? thanking you :)

    I am trying to update the new settings on my iphone 4s but every time I plug in to update it tells me i need to change my media sync options and I'm unsure how to do this? Can anyone help? thanking you

    What exactly does the message say?

  • SIR I NEED TO UNLOCK MY IPHONE 4 FOR FREE PLEASE HELP ME HOW I DO THIS...........

    SIR I NEED TO UNLOCK MY IPHONE 4 FOR FREE PLEASE HELP ME HOW I DO THIS..........

    Call your carrier and request it is generally the best idea.
    <Edited By Host>

  • Which planning function i have to use and how to write this planning fucnti

    Hi Bi Guru's,
    I have rolled out  BW SEM-BPS Planning Layout's for the Annual Budget in my organistaion.
    There are two levels of layout given for the each sales person.
    1)  Sales quantity to be entered Material and  country wise for all 12 months ( April 2009 to March 2010)
    2)  Rate per unit and to entered in second sheet, Material and country wise for the total qty entered in the first layout.
    Now i need to calculate the sales vlaue for each period and for the each material.
    Which planning function i have to use and how to write this planning fucntion.
    Please suggest me some solution ASAP.
    Thanks in Advance,
    Nilesh

    Hi Deepti,
    Sorry to trouble you...
    I require your help for the following scenario for caluclating Sales Value.
    I have Plan data in the following format.
    Country   Material    Customer    Currency    Fiscyear    Fiscper           Qty         Rate        Sales Value
    AZ          M0001      CU001          #             2009          001.2009        100.00                        
    AZ          M0001      CU002          #             2009          001.2009        200.00                        
    BZ          M0001      CU003          #             2009          001.2009        300.00
    BZ          M0001      CU003          #             2009          002.2009        400.00
    BZ          M0002      CU003          #             2009          002.2009        300.00
    AZ          M0001       #               USD          2009             #                                 10.00
    BZ          M0001       #               USD          2009             #                                 15.50
    BZ          M0002       #               USD          2009             #                                 20.00
    In the Above data the Rate lines are entered in the Second Layout, Where the user enters on the Country Material Level with 2009 value for FISCYEAR.
    I am facing problem with this type of data. 
    I want to store the sales value for each Material Qty.
    Please suggest some solution.
    Re
    Nilesh

  • Hi, I've checked how to use kannada keyboard in Yosemite. But, there are some 'vattu forms' and other grammar in Kannada language that I don't know how to use it. For eg, Preetiya taatanige nimma muddu mommagalu maduva namaskara? How to write this?

    Hi, I've checked how to use Kannada keyboard in Yosemite. But, there are some 'vattu forms' and other grammar in Kannada language that I don't know how to use it. I know how to change between the keyboards and can also view keyboard. However, For eg, 'Preetiya taatanige nimma muddu mommagalu maduva namaskara' How to write this? If anybody can answer this, very much appreciated.
    Thanks in advance for your reply.

    In general, you need to use the "f" (kannada qwerty keyboard) or "d" key (kannada) between letters to make special forms.  Also you may need to adjust the typography settings of the font, which is done by doing Format > Font > Show Fonts > Gear Wheel > Typography as shown below.  If you can provide screenshots or more detailed info on things you cannot make, I can perhaps help.
    It is important to note that MS Word for Mac does not support Indic scripts -- any other app should work OK.

  • How to write this code ?

    I need to write 3 classes that each one can get to the other with the same instance of the class , so how do i write this code ?
    thanks a lot

    try out singleton pattern with all the three classes. following link may help...
    http://www.javareference.com/jrexamples/viewexample.jsp?id=25

  • I have a problem in my iphone 4 with wi-fi after update to IOS6 please can help my how can solve this problem?

    I have a problem in my iphone 4 with wi-fi after update to IOS6 please can help my how can solve this problem?

    Nope
    One needs to press the home and sleep / wake keys together for the phone to reset
    The other thing I could recommend
    Let the battery run out and the phone completely "die"
    It may take a day or two with it not being used
    Then plug it in to charge and see if there is any change in behavior
    If you cannot get this to work - you may need to bring it to an Apple store

Maybe you are looking for

  • My iPod touch wont charge or turn on?

    My iPod touch was not fully charged but it had some charge and then it just turned off and now it won't turn back on. I plugged my iPod touch into charge and the red battery and lightning symbol comes on but that is still there a couple of hours late

  • My iBook G4's HD won't mount on startup

    Hi all, First time problems with my iBook G4, and therefore, first time post here. It all started earlier today when Firefox crashed and I rebooted in order to get it (Firefox) to reopen. When the iBook restarted, it kept hanging on a blue screen aft

  • How to set validtion on hmlb:inputfield

    hi   I want to set a validation on htmlb:inputfield on client side.That whenever user enter wrong entry in inputfield a alert will pop. Thanks, Aashish

  • Display of tables

    When converting a PDF file to Excel the fromating of a table was lost and all the data ended up in the 1st column. How do I get the data in its respective columns?

  • IBM Thinkpad T41 RAM

    Will this work for my T41? http://cgi.ebay.com/1GB-DDR-PC2700-333MHz-ECC-REGI​STERED-MAJOR-BRANDS_W0QQitemZ120372979994QQcmdZVie​... if not what about these search terms? http://shop.ebay.com/items/_W0QQLHQ5fBINZ1QQLHQ5fI​ncludeSIFZ1?_nkw=PC2700+333M