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 (the question had like ~50) in this case and the stars stand for one each.
I like to do some random programming in my spare time but this one just confuses me. How would I declare the variables as '140-159' etc. because all I have seen were either letters or words. So basically I'm lost from the first moment.
I would ask my IT teacher but he is not really a Java Expert, so I googled a bit and got to this forum.
I have tried to rewrite the '140-159' to 'a' and so on make life easier but it just doesn't seem to work. And I have no clue on how to convert the number of each to be displayed in stars like above.
package javaapplication1;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
*
* @author moneycode
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args)throws IOException {
// TODO code application logic here
int a;
int b;
int c;
int d;
a=0;
b=0;
c=0;
d=0;
int marks;
BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
System.out.println("Enter marks of student: ");
marks = Integer.parseInt(br.readLine());
if (159>=marks && marks>=140)
a = a+1;
if (179>=marks && marks>=160)
b = b+1;
if (180>=marks && marks>=209)
c = c+1;
if (210>=marks && marks>230)
d = d+1;
System.out.println(a);
System.out.println(B)/>;
System.out.println(c);
System.out.println(d);
I know the code looks very incomplete with many gaps but these are the points where I'm stuck. The book didn't have example on these type of questions
Key questions:
-How do I declare a number as variable?
-How do I create a loop in this example?
-How do I display the counted number of the variables as 'stars'.
This question has been in my mind for the past week or so and I need to return the book just before Christmas so I would like to get this example and understand it before i have to give it back.
Anyway, I would really appreciate any help.
This post has been edited by macosxnerd101: 11 December 2010 - 05:46 PM
Reason for edit:: Please keep all correspondance via the forums. Do not use the PM system to collaborate.

New Topic/Question
Reply



MultiQuote






|