Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Why won't my program run?

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Why won't my program run?

    import java.util.ArrayList;
    import java.util.Iterator;

    public class EWS_Engine {

    ///Task 2.1
    public int EWS(int hr, float bp, float temp, int rr, int spo2){

    //RR

    int ews=0;

    if ( rr <= 8)
    {
    ews = +3;
    }

    else if ( rr <=11)
    {
    ews = +1;
    }


    else if ( rr <=24)
    {
    ews = +2;
    }

    else if ( rr >= 25)
    {
    ews = +3;
    }

    //SPO2


    if ( spo2 <=91)
    {
    ews = +3;
    }

    else if (spo2 <=93){
    ews = +2;
    }

    else if (spo2 <=95){
    ews = +1;
    }

    //HR

    if ( hr <=40)
    {
    ews = +3;
    }

    else if (hr <=50){

    ews = +1;
    }

    if (hr >=131){
    ews = +3;
    }
    else if (hr >=111){
    ews = +2;
    }
    else if (hr >=91){
    ews = +1;
    }

    //BP

    if ( bp <=90)
    {
    ews = +3;
    }

    else if (bp <=100){
    ews = +2;
    }

    else if (bp <=110){
    ews = +1;
    }

    else if (bp <=220){
    ews = +3;
    }

    //Temp

    if ( temp <=35)
    {
    ews = +3;
    }

    else if (temp <=36){
    ews = +1;
    }

    if (temp >=38.1){
    ews = +1;
    }

    else if (temp >=39.1){
    ews= +2;
    }

    return ews;
    }


    //Task 2.2
    public int EWS(VitalSign data){
    //input correct variables into other ews method
    return EWS(data.getHr(),data.getBp(),data.getTemp(), data.getRr(), data.getSpo2());
    }
    }

    return EWS(data.getHr(), data.getBp(), data.getTemp(), data.getRr(), data.getSpo2());
    }

    //Task 2.3
    public ArrayList<String> fuzzyEWS(ArrayList<VitalSign> data) {
    ArrayList<String> traffic = new ArrayList<String>();
    for(int i =0;i < data.size();i++) {

    if (EWS(data.get(i)) <= 1) {
    traffic.add("Green");
    }
    else if (EWS(data.get(i)) <5) {
    traffic.add("Amber");
    }
    else if (EWS(data.get(i)) >= 5) {
    traffic.add("Red");
    }
    }
    return traffic;
    }
    public boolean testFuzzyEWS(ArrayList<VitalSign> data,ArrayList<String> correct_answers) {
    boolean test = true;
    fuzzyEWS(data);

    for (int i =0; i<data.size();i++){
    if (!data.get(i).equals(correct_answers.get(i))) { test = false;}
    }
    return test;

    }

    }
    //Task 2.4
    public void assignTimestamp(int interval, ArrayList<VitalSign> data) {
    for (int i =0;i<data.size();i++){
    data.get(i).setTimestamp(i * interval);
    }

    }

    public void printEWSMessage(String path, int interval, long start, long end) {
    ArrayList<VitalSign> samples = DataImporter.importFromDataFile(path);
    ArrayList<VitalSign> sampleinterval = new ArrayList<VitalSign>();
    assignTimestamp(interval, samples);

    //Changes start and end to the index of the array it corresponds to
    start = start + (start%interval);
    start = start / interval;

    end = end - (end % interval);
    end = end /interval;

    if (start>end){
    long whatstartwas = start;
    start = end;
    end = whatstartwas;
    }

    // If end is larger than array size
    if (end>samples.size()){
    end = samples.size();

    }
    else if (end <0) {
    end = 0;
    }
    if (start < 0){
    start = 0;
    }

    else if (start > samples.size()){
    start = samples.size();
    }


    for (int i=(int)start;i<end;i++){

    sampleinterval.add(samples.get(i));


    }
    ArrayList<String> traffic = fuzzyEWS(sampleinterval);
    for (int i=(int)start;i<end;i++){
    System.out.println(traffic.get(i));
    }

    }
    }


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    4,778
    My Mood
    Mellow
    Thanks
    175
    Thanked 625 Times in 612 Posts

    Default Re: Why won't my program run?

    Please read this topic to learn how to post code correctly and other useful tips for newcomers, and then fix your post.

    If you're getting error messages when you compile and/or try run, post those. Otherwise, describe how what is happening does not meet your expectations. Provide a copy of the console output, if applicable.

  3. #3
    Junior Member
    Join Date
    Oct 2013
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Why won't my program run?

    Not going to bother tracing that since it's not embedded. General tip for fixing the problem, identify whether a run-time error is occurring or a syntax error. If it's a run-time then check things that Java doesn't allow (such as division by zero). If it's a syntax error then check your identifiers etc.

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    4,778
    My Mood
    Mellow
    Thanks
    175
    Thanked 625 Times in 612 Posts

    Default Re: Why won't my program run?

    Not going to bother tracing that since it's not embedded.
    What does that mean, specifically "embedded"?

Similar Threads

  1. Compiled .jar won't run when using .wav-files.
    By EatMyBible in forum AWT / Java Swing
    Replies: 6
    Last Post: May 22nd, 2013, 06:23 PM
  2. GUI won't run properly once panel is added
    By mwardjava92 in forum AWT / Java Swing
    Replies: 4
    Last Post: February 23rd, 2013, 12:41 PM
  3. Replies: 8
    Last Post: February 12th, 2013, 04:45 AM
  4. Program won't run help!
    By iridebmxnj in forum What's Wrong With My Code?
    Replies: 5
    Last Post: July 26th, 2012, 09:00 PM
  5. HELP! My applet won't run on a web browser....
    By coolidge in forum Java Applets
    Replies: 4
    Last Post: October 21st, 2011, 08:52 AM