I'm creating a program that caluclates the area of a triangle & rectangle

Hi. I am reposting this topic in order to post it correctly. I will begin with my questions. I am to ask user to enter either rectangle or triangle to find the area of shape or to hit X to terminate the program. Have I coded this correctly? I am to use while and if loops which calls methods from CalculateAreaOfShapes. I have not attempted the if loops because I'm just not sure how to do them. If someone could give me some suggestions I'd apppreciate it. Next, if user enters Rectangle, I am to call calculateAreaOfRectangle() Have I coded this correctly? Also, If user enter Triangle, I am to call calculateAreaOfTriangle() Have I coded this correctly? The program should not terminate until X is entered. My code goes as follows:
import java.util.Scanner;
public class ModifiedTestCalculateAreaOfShapes
     public static void main(String[] args);
          Student Royce = new Student();
          //call student class's print method from student
          Royce.printMyInfo();
          //Welcome to Royce's modified TestCalculaterAreaOfShapes Program!
          System.out.println("Welcome to the Royce ModifiedTestCalculate area program");
          System.out.println("Please enter t to calculate area of triangle or r rectangle");
         //create a Scanner object name sc
          Scanner sc = new Scanner(System.in);
         //modifing this assignment so that the user has a choice until choice isn't equal to "r" or "R", or "t" or "T".
         String choice = ("y");   //Declare the variable to hold the name
         while(!choice.equalsIgnoreCase ("x"));   //Begin program loop
              //get the users choice "t" or "r"
               System.out.print ("Enter (t/r): ");
               String user = sc.next();
                System.out.print("Enter shape: ");
                double shape = sc.nextShape();
                System out.println("Please enter t to calculate area of triangle, r for recctangle or x to quit\n")
                //Asking the user to make a choice.
                          //create a Scanner object for if statements/
                          if(choice1.equals("t"))  //If choice is t then call calculateAreaOfShapes for my code
                                          //calculate the area of a Rectangle and a Triangle
                                        CalculateAreaOfShape.Shapes = new CalculateAreaOfShapes();
                                        double TriangleArea = Shapes.calculateAreaOfTriangle(height*base)/2
                                        else if(choice1.equals("r"));
                                                  double RectangleArea = Shapes.calculateAreaOfRectangle(height,width);
                         //display the area for each
                         String message = "Area for triangle: " + areafortriangle + "\n"
                                           + "Area for rectangle:" + areaforrectangle + "\n"
                                           + "Total area:        " + total + "\n";
                         System.out.println(message);
                         //see if the user wants to continue
                         System.out.print(Continue? (r/t): "){code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

No, let's continue in your original thread:
[http://forums.sun.com/thread.jspa?threadID=5390499]

Similar Messages

  • Create a program that recognizes the human face , any API or idea?

    Hi , I try to create a program that recognizes the human faces, taking images from a webcam , but i don´t know how do it , any API or idea?

    shays wrote:
    sabre150 wrote:
    malcolmmc wrote:
    Don't be so negative.I can never understand why negative realism should be so looked down upon. I also can't understand why verbal abuse is looked down on when it can be taken so constructively. In fact I feel the same about physical abuse, why do people shy away from it when it clearly shows how we really feel. Who needs courtesy, it doesn't do anyone any good. And lets take off the turn signal on cars, I don't need some light to tell you that I am about to cut you off. And we should definitely use the car horn more often. Any time I see an ugly car I get right behind them and lay on the horn. What's wrong with that. ; )So you want me to be unrealistic? So you want me to be upbeat about the OP's chance of creating a face recognition program? So if I see you about to jump off a cliff you want me to say - go for it, it won't hurt much, you will gain much from the experience?
    And where was this verbal abuse? In reply #4 I was sarcastic (as you are in your post) but to my mind not abusive. In reply #6 I was critical of the OP's approach but to my mind not abusive.
    Get real.

  • Hello, I trying to create a program that would run a household furnace. I can't find a way to set timers for the ignitor,flame sensor and blowers. Any thoughts.

    Hello, I'm trying to create a program that would run a household furnace. I can't find a way to set timers foe the ignitor,flame sensor and blowers. Any thoughts would be greatly appreciated. Thanks, primetime

    In the detailed help for the event structure there is a link to caveats and recommendations for using event structures.  It is a good starting point.
    It is courteous to let the Forum know when your questions are related to a school assignment or homework.  We are glad to help you learn LabVIEW, but do not do your homework for you.
    You have learned the major disadvantage of the sequence structure: It must run to completion before anything else can happen.
    If you are building a state machine (typically a while loop with shift registers enclosing a case structure with one case per state) and having trouble with timing, then think about your requirements. Apparently you have some time delays, but under certain conditions you must terminate a delay/wait and do something else.  One way of doing this is to have a Wait state.  The wait state has a short delay, determined by the minimum time you can delay responding to a changed condition, and a check to see if the required elapsed time has occurred.  If the time has not elapsed, the next state is the Wait state again.  The state machine can repeat any state as often as necessary.  So a 15 second delay could be implemented by going to a Wait state with a one second wait 15 times. Any error or new command will see a response in no more than one second.
    Lynn

  • How to create a program that accepts 5 digits from the user between 0 and 9

    how to create a program that accepts 5 digits from the user between 0 and 9 then put them in ascending order using link-list method..

    You can use a scanner to get user input from the command line.
    import java.util.*;
    public class Test {
        private List<Integer> list;
        private Scanner in;
        public static void main (String... args) {
            new Test ();
        public Test () {
            list = new LinkedList<Integer> ();
            in = new Scanner (System.in);
            for (int i = 0; i < 5; i ++) {
                System.out.format ("Please enter a number (%d more): ", (5 - i));
                list.add (in.nextInt ());
            Collections.sort(list, new Comparator<Integer> () {
                public int compare (Integer i1, Integer i2) {
                    return i2 - i1;
            System.out.println (list);
    }

  • Creating java program that orders 3 numbers in ascending order using if els

    Does anyone know what code to use for creating a java program that uses the if else operators to order 3 variables in ascending order?

    nar0122 wrote:
    correct on the homework assumption...you have a good nose...the thing is...i know i need to make an if statement saying if a is less than b, and a is less than c...print a first...but how do i get it to "print a" first? if a is less than c and b...and so on for b and c? sorry if that was confusing...
    int a = ..., b = ..., c = ...;
    if(a > b AND a > c) {
      print a
      if(b > c) {
        print b, print c
      } else {
        print c, print b
    etc.

  • How do I create a filter that bypasses the in page and goes directly to spam rather to delete?

    How do I create a filter that bypasses the in page and goes directly to spam rather than to delete?

    From your question I'm going to guess you are talking about Mac Mail.
    If you are talking about a RULE then the "Perform the following actions:" would be to select "Move Message" to mailbox "Junk" instead of "Delete Message."
    If you are talking about something else then please give more information.

  • Creating that blur using my brush my entire image changes too and becomes blurry. Not only that but the area I painted also becomes over exposed. What can I do am I missing something here all I want is to blur a section and not change the rest of the area

    Creating that blur using my brush. When I paint the area, which highlights in red, I bring the clarity down to create more of that blur but what ends up happening is that my entire image changes too and becomes blurry. Not only that but the area I painted also becomes over exposed. What can I do am I missing something here all I want is to blur a section and not change the rest of the area I am painted by automatically becoming over exposed. Does anyone else have this problem that can help me?

    Quote
    Do you think I should try to find a cheap mobo to OC my current CPU?  How about trying to find one (mobo) used?  I fear that my only realistic choice will be to scrap the CPU and eventually buy a new mobo and CPU, but as the CPU was only released just under two years ago I would value being over to overclock it with a cheap enough mobo to last me another year or so.
    Who knows what additional problems may be run into by switching mainboards & such. The OS would have to be reinstalled fresh, etc. Money wise, it wouldn't make a lot of sense to invest more into a system that is rather outdated. The small performance gain making the switch to another board using the CPU you have, just doesn't really make much sense, especially if what you have now is completing the tasks asked of it. Save up some money, set it aside for a future build. There are plenty of new platforms in the works.

  • Shellext dlls are not preserved across upgrades, but the programs that installed them are

    classic 32 & 64 bit shell extension dlls (%windows%\system32\shellext resp %windows%\syswow64\shellext) are not preserved across system upgrades, yet the programs that installed the extensions are. copying them manually from windows.old is a workaround,
    but probably not viable for normal users...
    very simple, basic tool that is affected by the problem: http://code.kliu.org/hashcheck/
    the problem has been around since the first windows 10 build, and is still present in 10061

    Hi heldchen,
    Thanks for posting and sharing this in forums.
    For the current situation, I am not able to test this out. I will setup a test, and once I have the same symptom, I will submit feedbacks from my side.
    Besides, fi any further suggestions or problems, please take use of feedback tool.
    Regards
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • I would like to create a form that gives the user opportunities to provide information on as many as 50 projects. Does Adobe FormsCentral allow for this "expandable" type of form, such that if someone only has 10 projects, they can complete the form as ea

    I would like to create a form that gives the user opportunities to provide information on as many as 50 projects. Does Adobe FormsCentral allow for this "expandable" type of form, such that if someone only has 10 projects, they can complete the form as easily as someone with 50 projects. In other words, is there a way to make the form "expandable?"

    Hi Ms Buckner,
    Yes, you can do this with the Show/Hide "Skip" logic rules.
    1. Suppose, for example, you have your first ten projects showing by default.
    2. At the end of those fields, you would have a Yes/No question asking if the person wanted to add more projects.
    3. If they answer "No", they move on to the next section/area/question/etc.
    4. If they answer "Yes" you have the form display ten more project fields that you had already included, but you had hidden up to this point.
    5. Repeat steps two, three, and four as often as needed. (It helps that you can copy and paste fields, including groups of questions, so you don't have to manually re-create them each time.)
    It means you must anticipate the maximum number of times you want to provide project fields, but you've already done that, and you have to build the form with that maximum number, but only display smaller portions at a time until they have filled in all they need.
    I hope that helps,
    Brian

  • How to create a program that will accept a series of strings of 0 and 1 onl

    how to create a program that will accept a series of strings of 0 and 1 only then displays 0 as 48 and displays 1 as 49.

    Isn't one thread enough for your homework?
    http://forum.java.sun.com/thread.jspa?threadID=5253850&messageID=10051155#10051155

  • Can I create order forms that calculate the exact total with taxes?

    Can I create order forms that calculate the exact total with taxes?
    The customer needs to know exactly how much everything will cost before submitting. I can handle the actual payment portion manually.

    thanks for the info;
    I'll inform the admin dude that they need an upgraded acrobat to do forms.

  • Outline path to create an outline that includes the rounded edge?

    In illustrator CS6 I have a line with a rounded endpoints. When I try to OUtLINE PATH - it will clip off the rounded edge -- as if I'm asking AI to outline a path with a non-rounded edge. How can I get outline path to create an outline that includes the rounded edge? Many thanks!

    Karen,
    It sounds like something that may require something from this list.
    The following is a general list of things you may try when the issue is not in a specific file (you may have tried/done some of them already); 1) and 2) are the easy ones for temporary strangenesses, and 3) and 4) are specifically aimed at possibly corrupt preferences); 5) is a list in itself, and 6) is the last resort.
    1) Close down Illy and open again;
    2) Restart the computer (you may do that up to 3 times);
    3) Close down Illy and press Ctrl+Alt+Shift/Cmd+Option+Shift during startup (easy but irreversible);
    4) Move the folder (follow the link with that name) with Illy closed (more tedious but also more thorough and reversible);
    5) Look through and try out the relevant among the Other options (follow the link with that name, Item 7) is a list of usual suspects among other applications that may disturb and confuse Illy, Item 15) applies to CC, CS6, and maybe CS5);
    Even more seriously, you may:
    6) Uninstall, run the Cleaner Tool (if you have CS3/CS4/CS5/CS6/CC), and reinstall.
    http://www.adobe.com/support/contact/cscleanertool.html

  • Is there any calendar /contact program that has the depth of power-on Now up-to-date that will run on Lion?

    is there any calendar /contact program that has the depth of power-on Now up-to-date that will run on Lion?

    This can be done easily with ethernet.
    Please follow the instructions strictly.
    To make it easier I want you to do this overnight so you can turn off all your current connection to the internet.
    Just go to the airport fan in to the top right and turn airport off.
    Get ethernet cable and connect the laptop to the TC lan port.. ie <-> ones.
    Press and hold the reset on the TC for about 10sec. until the front led flashes rapidly.
    Open the airport utility.. go to manual setup and change the wireless to off. (so other people around you cannot join your network of one).
    Ignore all the errors.. they won't stop the backup working.
    Go to the TM and reselect the backup target disk as the TC.
    It should start after 2min and run through to completion.
    That is it.. for a backup of many GB it might take a few hours.. so make sure the laptop has power plugged in and the sleep is off.. (on early ones I think this is needed but I am a late arrival to the scene).. sleep doesn't affect later OS.

  • I have Adobe premiere 12 elements I have Buy it but this program is Corrupt. the are no sound on the time line. I have sound in my computer, this is no problem, I can listen every another things but NO Elements 12 OK I make ia video take down to the time

    i have Adobe premiere 12 elements I have Buy it but this program is Corrupt. the are no sound on the time line. I have sound in my computer, this is no problem, I can listen every another things but NO Elements 12 OK I make ia video take down to the time line. Video is OK BUT NO sound I have makit in 2 veeks from monday to next vek here whit this very bad program so i go to garbags I think I buy a another program is be better and have a Sound. This is very bad I am not god to English. I Have a pro camera and I will have a god support but this is very bad. I is bad to English. But this Program I buy i think this is very Corrupt. The mast find a sound in this program. I cvan not understan if You can sell this very bad program Videoredigering and this program have nothing sound. This is crazy.

    i have Adobe premiere 12 elements I have Buy it but this program is Corrupt. the are no sound on the time line. I have sound in my computer, this is no problem, I can listen every another things but NO Elements 12 OK I make ia video take down to the time line. Video is OK BUT NO sound I have makit in 2 veeks from monday to next vek here whit this very bad program so i go to garbags I think I buy a another program is be better and have a Sound. This is very bad I am not god to English. I Have a pro camera and I will have a god support but this is very bad. I is bad to English. But this Program I buy i think this is very Corrupt. The mast find a sound in this program. I cvan not understan if You can sell this very bad program Videoredigering and this program have nothing sound. This is crazy.

  • Need to create a program to test the object

    Hi All,
    My requirement is to create a program which similarly to SLIN i.e Extended check
    This should show all the syntax error , warning error and etc.....
    Regards,
    Reni

    Write a BDC program that calls SLIN and provide the program name, SLIn will take care of everything else.

Maybe you are looking for