The Artima Developer Community
Sponsored Link

Java Answers Forum
Need help with writing a code for following problem

1 reply on 1 page. Most recent reply: Dec 12, 2010 5:06 AM by Vincent O'Sullivan

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Jimmy Flloyd

Posts: 1
Nickname: desiredid
Registered: Dec, 2010

Need help with writing a code for following problem Posted: Dec 11, 2010 5:42 AM
Reply to this message Reply
Advertisement
Basically, I'm a high school student who is aiming to go to University to study Computer Science next year. So sometimes in my spare I like to play around with codings in Java using Netbeans for example.
So I have been using a textbook to assist me (Beginning Java objects, borrowed that from local library) and I have come across an example which has completely caught me out and makes me look like a super noob.

I googled around a bit but couldn't find anything.

The question kind of looked like this:

So for example, a research institution wants to make a graphical display to show how many high blood pressure patients were at a different stage of BP (in systolic mm Hg) at a certain time.
The program should let you enter in the different heart beat rates until the entered value exceeds 230 (the maximum value in the blood pressure chart).
The program should display a histogram and like the following:
140-159 ********
160-179 ***
180-209 ***
210-230 *
I used 15 patients in this case and the stars obviously stand for one each.

How would I write a program for this?


Vincent O'Sullivan

Posts: 724
Nickname: vincent
Registered: Nov, 2002

Re: Need help with writing a code for following problem Posted: Dec 12, 2010 5:06 AM
Reply to this message Reply
I guess that there are several ways that this could be done. One might be to write a class with a main method and to execute it in the usual way. In the main method create an empty list of integers and then create a loop that repeatedly asks the user to enter a number (the heart rate) and stores the number on the list. If the user enters a nmber over 230 then the loop exits. Finally create another loop that counts all the heart rates in the 0-10 range and prints that line, looping around and adding 10 to the start and endpoints of the range and printing a line until 230 is reached.

If you're working your way through the book then each of the constructs required should already have been explained, otherwise come back here if you have a more specific question.

Flat View: This topic has 1 reply on 1 page
Topic: Virtual Machine Launcher Previous Topic   Next Topic Topic: Design for performance

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use