Banging my head against the wall

I am working on a program to calculate bmi. I have input to read in age range and gender. When I enter input to look at both genders, it does not calculate the total patients or calculate the averages. Any help would be appreciated.
//prompts user for inputs
System.out.print("Enter the file name: ");
System.out.flush();
filename = console.nextLine();
System.out.println("What age range would you like to examine?");
System.out.print("Enter starting age: ");
System.out.flush();
agelooking = console.nextInt();
System.out.print("Enter ending age: ");
System.out.flush();
agelooking2 = console.nextInt();
System.out.println("What gender would you like to examine?\n"
+ "Enter F for Female; M for Male; B for Both genders: ");
genderlooking = console.next().charAt(0);
//reads in gender and age range
while (inFile.hasNext()) {
//read in gender
gender = inFile.next().charAt(0);
if (genderlooking == gender){
//read in age range
age = inFile.nextInt();
// filters logic for age
if(age >=agelooking && age2 <=agelooking2) {
totalpatients++;
//reads in height and weight
weight = inFile.nextInt();
height = inFile.nextInt();
//calculates bmi
bmi = (weight * weightkg) / Math.pow(height * heightm, 2);
totalbmi = bmi + totalbmi;
//takes bmi calculation and filters into 4 categories
if (bmi < 18.5) {
underweight++;
if (bmi >= 18.5 && bmi <= 24.9) {
normal++;
if (bmi >= 25.0 && bmi <= 29.9) {
overweight++;
if (bmi >= 30) {
obese++;
} //end while
//calculates averages
averagebmi = totalbmi/totalpatients;
averageUnderweight = underweight/totalpatients;
averageNormal = normal/totalpatients;
averageOverweight = overweight/totalpatients;
averageObese = obese/totalpatients;
//writing results to output file
outfile.println("Results of the BMI analysis for " + practiceName + ": \n\n");
if (gender == 'm' || gender == 'M')
Gender = "Male";
else
if (gender == 'f' || gender == 'F') {
Gender = "Female";
else
Gender = "Both";
outfile.println("Patients of " + Gender + " gender in age range of " + agelooking
+ " to " + agelooking2);
outfile.println ("Number of patients examine: " + totalpatients);
outfile.printf ("%.1f percent Underweight%n", averageUnderweight * 100);
outfile.printf ("%.1f percent Normal%n", averageNormal * 100);
outfile.printf ("%.1f percent Overweight%n", averageOverweight * 100);
outfile.printf("%.1f percent Obese%n%n", averageObese * 100);
outfile.printf("Average BMI: %.1f",averagebmi);
inFile.close();
outfile.close();
System.exit(0);
}

Because this line will never be true is you are looking for both genders, unless one of the records in teh file was entered as B for gender (Hermaphrodite?)
if (genderlooking == gender){
//Change that line to this
if(genderlooking == 'b' || genderlooking == 'B' || genderlooking == gender){

Similar Messages

  • Motion 4 + layered PSD files = me banging my head against the wall

    I posted this same question in the other M4/PSD file problem, but it was marked as answered (and the answer isn't working for me).
    I'm having a similar problem, but changing the resolution to the exact max of 2896x2896 doesn't work for me...and neither does any smaller resolution for some reason.
    Today, my layered PSD file is at least not experiencing the crazy tile-effect you included in your posted images, but it is now:
    1) always converting the top layer of the PSD file to a flattened image of the whole file.
    2) ignoring/mutating my alpha channel information, as areas that should be transparent and smoothly masked off are now opaque and/or blocky.
    My images are large, but I need to keep them large for dollying in real closely when i fly a camera through the scene. This is not a problem in After Effects, but I also need to do a lot of these 2.5D animations and several need particle/replicator effects... and I just work much much faster in Motion than AE. I don't remember having this problem with Motion 3 at all, but I can't say I've done a scientific comparison (nor do I want to uninstall M4 for M3).
    My system info can be found here:
    [IMG]http://i36.tinypic.com/2n744di.jpg[/IMG]
    [IMG]http://i33.tinypic.com/28cks42.jpg[/IMG]
    Original PSD file info:
    [IMG]http://i37.tinypic.com/amdr9v.jpg[/IMG]
    [IMG]http://i36.tinypic.com/99kv1g.jpg[/IMG]
    [IMG]http://i33.tinypic.com/3355w8x.jpg[/IMG]
    [IMG]http://i37.tinypic.com/1zb6y3m.jpg[/IMG]
    [IMG]http://i35.tinypic.com/9i5rhz.jpg[/IMG]
    Motion 4 info:
    [IMG]http://i38.tinypic.com/es40v4.jpg[/IMG]
    [IMG]http://i37.tinypic.com/2crva83.jpg[/IMG]
    [IMG]http://i35.tinypic.com/2e3popz.jpg[/IMG]
    [IMG]http://i37.tinypic.com/jrv8tz.jpg[/IMG]
    [IMG]http://i37.tinypic.com/28rh6hs.jpg[/IMG]
    Any help is appreciated!
    Thank you!

    I can't believe I didn't see that! I scanned them in 24-bit color but they are B&W images anyways, so I'm not sure why or how they ended up as 8-bit greyscale... maybe has something to do with the lousy HP dinosaur-of-a-scanner and it's weird proprietary HP interface (couldn't get it to interface with PS4 and don't use it enough to fuss with it).
    Thanks!
    I think that was about the quickest/least-frustrating help forum experience ever =)

  • Portfolio question that I am banging my head against the wall trying to figure out...

    I want to build a portfolio with categories. You click something and the appropriate slideshow or lightbox appears or comes into the scene. The troubling part is I dont want to scroll anywhere. I just want 6 categories and each respective lightbox all in one place. Any ideas?

    In this case, I would reccomend you use something like a tabbed panel widget and place a lightbox for each inside a specific panel.  You could create the overall layout for the lightbox display in the first panel and copy it across the rest to maintain design consistency.
    Cheers,
    Justin

  • Banging by head against the wall over FlashVars

    OK. This was supposed to be a quick few minute edit that has consumed hours. There is something wrong but I can't find it.
    All I want to do is read a number in from a FlashVar. These are the relavent code snippets.
    HTML
    <param name="FlashVars" value="pid=1" />
    AS3
    var keyStr:String;
    var valueStr:String;
    var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
    for (keyStr in paramObj) {
         valueStr = String(paramObj[keyStr]);
         if(keyStr == "pid") strFlashVarPID = valueStr;
    if(valueStr=="1") pid=1 else pid=2;
    I am always getting a pid=2.
    Why? How can I troubleshoot this? I can't see trace values when viewing the SWF from a web page.

    Here is all the HTML code:
              <div id="flashContent">
                   <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="715" height="800" id="my" align="top">
                        <param name="movie" value="my.swf" />
                        <param name="quality" value="high" />
                        <param name="bgcolor" value="#000000" />
                        <param name="play" value="true" />
                        <param name="loop" value="false" />
                        <param name="wmode" value="window" />
                        <param name="scale" value="showall" />
                        <param name="menu" value="true" />
                        <param name="devicefont" value="false" />
                        <param name="salign" value="" />
                        <param name="allowScriptAccess" value="sameDomain" />
                        <param name="allowFullScreen" value="true" />
                        <param name="FlashVars" value="pid=1" />                    
                                    <!--[if !IE]>-->
                        <object type="application/x-shockwave-flash" data="my.swf" width="715" height="800">
                             <param name="movie" value="my.swf" />
                             <param name="quality" value="high" />
                             <param name="bgcolor" value="#000000" />
                             <param name="play" value="true" />
                             <param name="loop" value="false" />
                             <param name="wmode" value="window" />
                             <param name="scale" value="showall" />
                             <param name="menu" value="true" />
                             <param name="devicefont" value="false" />
                             <param name="salign" value="" />
                             <param name="allowScriptAccess" value="sameDomain" />
                             <param name="allowFullScreen" value="true" />
                             <param name="FlashVars" value="pid=1" />
                        <!--<![endif]-->
                             <a href="http://www.adobe.com/go/getflash">
                                  <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
                             </a>
                        <!--[if !IE]>-->
                        </object>
                        <!--<![endif]-->
                   </object>
              </div>
    By the way I am able to get the code to work if I put the pid on to the url like this:
    <object type="application/x-shockwave-flash" data="my.swf?pid=1" wi...
    I may just the URL for now but I want to know why the param is not working.

  • Banging my head on the wall about this

    Post Author: despec
    CA Forum: General
    Folks,Is there any way possible in CR 11.5 to "store" a field value to be compared with the next record's same field value?  I need to compare a previous date field within a record with a new date field within the next record to see if it is a consecutive day.  I just can't figure out how to do this using a formula, becase my "previous" date just becomes the current record date field. Help, my head is getting softer as we speak :-)David

    Post Author: Jagan
    CA Forum: General
    I assume you just want to use the Previous() or Next() function. Look them up in the help.

  • Banging My Head Against Grep Wall

    I'm trying to filter lines out of a log within a shell script, with line like this...
    cat log | grep -v "filter word" | grep -v "filter 2" > newLog
    ...but I cannot find the grep or egrep command for something slightly more complex than a simple match.
    I want to exclude (delete) all lines ending with "/" EXCEPT if they begin with "deleting".
    So a file which contains these 4 lines...
    this gets through
    deleting - this gets through/
    deleting - this gets through
    this does NOT get through/
    ...will result in this...
    this gets through
    deleting - this gets through/
    deleting - this gets through
    Thanks very much for any pointers. Maybe I shouldn't be trying it with just grep?

    This works for me at least for the small sample that you provide:
    grep '^deleting.*/$|[^>$' log > newLog
    What it lets through is:
    1. Lines that begin with deleting AND end in /
    2. Lines that do not end in a /
    I hope that this does what you need.
    Message was edited by: hungryjoe
    Message was edited by: hungryjoe
    Message was edited by: hungryjoe

  • I feel like I'm banging my head against a wall!!!

    I transfered my Itunes libruary to my External hard drive. Everything was going well until I updated my Itunes then I lost everything. The Itunes folder is still on my extenal hardrive. I have changed my itunes media folder location on my preferences but still nothing on my itunes. Can you please help?

    buddhautopia wrote:
    The Itunes folder is still on my extenal hardrive
    what happens if you launch iTunes while holding shift, click on choose library at the prompt, and select the iTunes folder on the external ?

  • Banging my head against the window

    No matter what I do, I have no control over the size of child windows. This is pretty simple, but it's ignoring me totally. Here's what I've got:
    // The container stuff seems to work fine. I'll include it here in case I've done something stupid in it that's affecting the child classes.
    public class MainFrame extends JFrame
    protected JDesktopFrame m_desktop;
    protected JPanel m_panel;
    MainFrame()
    m_panel = new JPanel();
    m_panel.setLayout(new BorderLayout());
    this.setContentPane(m_panel);
    m_desktop = new JDesktopPane();
    m_desktop.setDesktopManager(new DefaultDesktopManager());
    m_panel.add(m_desktop);
    public void AddChildWindow()
    MyChild child = new MyChild();
    child.setVisible(true);
    m_desktop.add(child);
    public class MyChild extends JInternalFrame
    private JPanel m_panel;
    private JScrollPane m_scrollPane;
    private JButton m_button;
    public MyChild()
    super("Title here", true, true, true, true);
    m_panel = new JPanel();
    m_scrollPane = new JScrollPane();
    m_button = new JButton();
    this.setContentPane(m_panel);
    m_panel.add(m_scrollPane);
    m_scrollPane.add(m_button);
    m_button.setsize(200,200);
    m_button.setText("This button is very very tiny for some reason.");
    What I need is the ability to add a single control to this child window (a JTable, if you must know), and be able to move the window around, and resize it, and see the control. If the control is larger than the window, I need to be able to scroll.
    What am I missing? I've tried lots of setSize() methods on stuff, and things like various LayoutManagers at different points, but nothing seems to make any difference. All I see is a child window with a single, tiny button, and if I resize it, it snaps back to tiny. Moving it around doesn't make it stick, either.
    Any help, hints, or examples are VERY appreciated!
    --- Eric

    what is the problem, that the button you are adding wont resize or the window wont resize?
    If the button wont resize it could be that you are using the JScrollPane.add() method which you shouldn't use anyway instead use JScrollPane.setViewportView()
    HM.

  • Banging my head against a brick wall

    Some background information: I currently have two phone lines, let’s call them line A and line B.
    At the beginning of September I decided to move by broadband to BT and signed up online for a Total Broadband package to be activated on line A (the line on which my previous broadband service was active). During the signing up process I was asked if I wished to save money and sign up to the line rental saver, which I did. I got my order confirmation by e-mail and thought all was well.
    Having ordered BT Broadband for line A,  I decided that I would cancel line B, as I had no use for it.
    Shortly after the initial order confirmation e-mail, I received a further e-mail and noticed it stated that new services were starting on both line A and line B, which confused me as I had never signed up for any changes to line B. So I called Customer Services to check out the situation and explained that I wished to cancel line B and did not understand why services relating to that line were mentioned in my e-mail. I was informed that BT was unable to do anything at the time due to there being an order on the line. However, I was told that if I called back once the broadband had been activated on line A, then everything could be sorted out.
    So, as soon as the broadband order had been completed on line A, I called back Customer Services to cancel line B. However, I was told that I had paid the line rental saver for line B and would lose that money if I cancelled the line. I checked my account online and, sure enough, BT had activated the broadband on line A but, inexplicably, had applied the line rental saver to line B.
    Immediately, I called Customer Services to sort out the problem: I wanted BT to change the line rental saver from line B to line A (as per my order) and cancel line B. However, I was told that it was not possible to change the line rental saver from one line to another. I tried to explain that the error was on the part of BT and that it was down to them to find a solution, only to be met by protestations that this was not possible. I have now spoken to customer services on three separate occasions to try and sort out the problem, without success. Twice I have requested call-backs from a manager and heard nothing either time.
    I have now reached the end of my tether as I do not understand why BT is claiming that they are unable to correct their own error. As a result of the situation, I am currently paying for a line I no longer want and am unable to cancel the line without losing a fair amount of money.
    Where did it all go wrong with BT customer service? I am sick of speaking to people who struggle to grasp the nature of issues and appear powerless to address any problems unless they are on their crib sheets. It is very frustrating that BT makes it impossible to escalate problems to managers when needed and I am incredulous that the Company is trying to claim that it is unable to sort out a billing error of its own making (particularly as I would imagine that the change of line rental saver from one line to another is simply a matter of changing some details on a computer system).
    I hope that someone here can offer some help or point me in the right direction, as I currently feel like I am banging my head against a brick wall and am very disappointed with BT’s response so far.
    Many thanks
    DJW

    Hi David, sorry to hear about your problems. If you click the link in my signiture below my posts the forum mods will be happy to look into this for you
    Contact The Mods
    Use Live Chat to speak to an advisor
    Charges for cancelling your contract early

  • I Want to Throw My SONY TRV350 against the wall!

    I HATE it!
    (I have another camera now, but still...)
    I have hours and hours and even more hours of 8mm, Hi8, and D8 footage that I am unable to capture into iMovie because my stupid camera is a peice of junk. Oh it works fine alone and without any connections but try to connect it to iMovie via Firewire and nodda... try to pass through via the analog connections (like you would a VCR) and the stupid picture is in BLACK and WHITE!!!!!
    Forgive the rant, but maybe someone here has found a solution.
    note: Doesn't work with Final Cut either.
    Dwaine

    Before you throw it against the wall.
    Do these steps, as I described to another guy a minute ago.
    With the computer off, AND the camera off, plug in the fire wire cord to the camera (4-pin) and to the computer (6-pin). Then turn on your camera FIRST and put the control knob in play mode.
    THEN START YOUR COMPUTER and open iMovie.
    Then switch iMovie to camera mode. A blue screen should come up saying "camera connected". That is all there is to it, plug and play no problems.
    I have on several occasions found that the camera will not show as connected in iMovie.
    If this happens, leave the camera connected, plugged in with fire wire, and in play mode. Restart the computer. Open iMovie and see if your camera is recognized in iMovie.
    WARNING!!!!!!!
    Plugging and unplugging the camera (Called "Hot Plugging") can sometimes solve this issue HOWEVER every-time you do this you risk frying the fire wire port on your camera and/or your computer.
    I FRIED THE FIREWIRE PORT ON MY $1200.00 PANASONIC CAMCORDER.
    Now my camera cannot be recognized by my computer rendering the camera useless for video editing. Repair costs for video cameras out of warrantee are OUTRAGEOUS. So I am looking for another camera.
    I hope this did not happen to you.
    If your fire wire port is fried, then you may throw it against the wall.
    In my case, Panasonic wants about $265.00 up front (NON REFUNDABLE) just to look at the camera, no guarantees that it can be repaired for less $$$ than the purchase price of a NEW High Definition camera.

  • HELP ME! BEFOR I HIT MY MAC AGAINST THE WALL

    I am having a huge issue every time I go on the internet. Everytime I click on a new link, and new tab opens up with (dating, mac backup, mac repair, backupmypc, and video download sites) HOW DO I GET RID OF the or stop them from popping up. Is there anything I can run to get rid of them. Please help its driving me up the wall. Also I have a Mac Book Pro 15' Retina Display 2012

    This should save your Mac from certain destruction.
    Please download and run "AdwareMedic" at the site below to remove adware. The App has been created by one of the long time contributors to this site.
    http://www.adwaremedic.com/
    To prevent this type of adware from reappearing on your computer, check out the article below.
    https://discussions.apple.com/docs/DOC-7471

  • Banging my head against a brick wall, please help!

    Hi can someone please help me.
    I keep coming up against this error, sometimes I manage to get rid of it through hours of tinkering, but still have not found out why it comes up. On theis new site i'm working on, i just can't get rid of it period.
    Here is the error.
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at workinprogress_fla::MainTimeline/frame21()
    at flash.display::MovieClip/gotoAndStop()
    at workinprogress_fla::MainTimeline/clickMenus()
    And here is the code on Frame 21.
    pic1.addEventListener(MouseEvent.CLICK, clickpic1);
    function clickpic1 (evtobj:MouseEvent) {
    //go to the section clicked on i.e menu page!
    gotoAndStop ("pic1");
    pic2.addEventListener(MouseEvent.CLICK, clickpic2);
    function clickpic2 (evtobj:MouseEvent) {
    //go to the section clicked on i.e menu page!
    gotoAndStop ("pic2");
    pic3.addEventListener(MouseEvent.CLICK, clickpic3);
    function clickpic3 (evtobj:MouseEvent) {
    //go to the section clicked on i.e menu page!
    gotoAndStop ("pic3");
    pic4.addEventListener(MouseEvent.CLICK, clickpic4);
    function clickpic4 (evtobj:MouseEvent) {
    //go to the section clicked on i.e menu page!
    gotoAndStop ("pic4");
    pic5.addEventListener(MouseEvent.CLICK, clickpic5);
    function clickpic5 (evtobj:MouseEvent) {
    //go to the section clicked on i.e menu page!
    gotoAndStop ("pic5");
    pic6.addEventListener(MouseEvent.CLICK, clickpic6);
    function clickpic6 (evtobj:MouseEvent) {
    //go to the section clicked on i.e menu page!
    gotoAndStop ("pic6");
    pic7.addEventListener(MouseEvent.CLICK, clickpic7);
    function clickpic7 (evtobj:MouseEvent) {
    //go to the section clicked on i.e menu page!
    gotoAndStop ("pic7");
    pic8.addEventListener(MouseEvent.CLICK, clickpic8);
    function clickpic8 (evtobj:MouseEvent) {
    //go to the section clicked on i.e menu page!
    gotoAndStop ("pic8");
    Can someone please help me out.
    Thanks
    Tom

    thanks for your replys.
    I have debugged the movie, and it is now saying the following
    Attemping to launch and connect to Player using URL /Volumes/Documents/Sketch Collective/Web Sketch/On the Go/Fuggles Website/Flash/Green Website/workinprogress.swf
    [SWF] Volumes:Documents:Sketch Collective:Web Sketch:On the Go:Fuggles Website:Flash:Green Website:workinprogress.swf - 2383999 bytes after decompression
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at workinprogress_fla::MainTimeline/frame21()[workinprogress_fla.MainTimeline::frame21:47]
    at flash.display::MovieClip/gotoAndStop()
    at workinprogress_fla::MainTimeline/clickMenus()[workinprogress_fla.MainTimeline::frame11:13 ]
    I am still clueless, every instance name seems absolutely fine and all in place.
    Any ideas?

  • OK Have iTunes on my PC all files converted to MP4 for the vids. It is recognised as it goes on but the new drag and drop does not like my iPad or wont copy files over. Any ideas before I smash it against the wall and buy an android so I can play stuff on

    Why wont my iPad accept MP4 Files in my iTunes library unless I sync it. I soooooooooooooo miss drag and drop to the side.

    Have your tried using the View menu item Show Sidebar?
    This will restore the function of iTunes 11 to what you find familiar.

  • I'm gonna throw it against the wall!!

    I've only had my ipod for about two weeks, and already, it's messed up. (It's the newest iPod video, the black 30gb)
    It was working fine, and I hooked it up to my computer to add some more music files. My screen saves went on, and actually went to the XP screen listing the users...which apparently caused my ipod to freeze.
    Now, when I connect the USB cable, the little arrow pops up on the bottom right tray (the green arrow icon), but iTunes doesn't start automatically and when I open it, it doesn't register my iPod.
    My iPod stays constantly on the "Do Not Disconnect" screen, and the hard drive is spinning, but that's all it does. And it also erased all of my songs, except for one at some point...
    I'm frustrated, and I bought it from Target. I was considering just taking it back and seeing if they'd do an exchange...Unless someone can tell me how to fix it!

    Have you Tried the 5R's yet? http://www.apple.com/support/ipod/five_rs/ Sounds like you may need to restore it using the iPod Updater.

  • Banging my head against data transfer to PC from L...

    Hi All,  I know that MS has brought out the transfer music, photos, videos and podcasts but thats not much use if you want your texts contacts ectera.  I have got the Backup set to automaticaly backup app list+settings, texts and photos to the cloud but for some reason its not happening.  I have SkyDrive on my phone and PC but I am still seeing empty empty folders in the SkyDrive.  To save my hair can anyone tell me how I can get my texts and photos onto my PC.
    Why has Nokia not created the PC Suite like that did for the Symbian Phones that was great.

    Please use the forum search function, this is asked and answered many times before.
    You have no access to the data backed up using the function on the phone. Video and photoscan be synced to your Skydrive or copied to a PC using the companion app or MTP.
    Contacts, calendars and skydrive are on outlook.com where you log in with your Microsoft account. or you can use a number of tools, especially Microsoft essentials to access the information on your PC. All these are built in to Windows 8.
    Reading the help available on windowsphone.com might also be a good plan.
    Click on the blue Star Icon below if my advice has helped you or press the 'Accept As Solution' link if I solved your problem..

Maybe you are looking for

  • Attachments included in Reply

    Currently any attachments in an e-mail are included when I reply. I would like the text to be quoted, but I do not want the attachment included. I have tried combinations of settings in the 'Compose' tab, but either I get no quoted text, or I get quo

  • PDPageDrawContentsToMemory for SDK 7.0.5?

    Hi, I want to save a single page with my plugin to an Image Format. I am already using CxImage to do so for selected Images in the Document, but now I also want to save the whole Page as shown in Acrobat to a jpeg file. I couldn't find very much Info

  • Just updated my iPhone and the background is white or sepia this is very painful to my eyes how do I put it back to normal plz

    Updated my iPhone now it's hard to see screen as it's sepia colour how do I change it back to normal, as it's hurting my eyes I will soon need glasses and it will all be apples fault So help

  • Init context node during runtime

    Hi together, i have a question concerning initialization of a context node during runtime. I designed my context like                    Parent Child1          Child2         Child3 The parent node is the only one where the attribute boldInitializati

  • ICal will not accept any event

    i add an event. Quit iCal and when opening iCal, the event is not saved..? any ideas? thanx!