I made a program telling if a CWE is safe.

Some mod said put it in blogs...put it in blogs it is lol.

http://www.megaupload.com/?d=G5G5DSW0

Code:
import java.io.*;
import java.util.*;
import java.text.*;
public class Tylenol
{
  public static void main(String[] args)
  {
    DecimalFormat a = new DecimalFormat(".00");
    Date date = new Date();
    double n = 1;
    do{
    try{
    System.out.println("    _/    _/    _/_/_/    _/_/    ");
    System.out.println("   _/  _/    _/        _/    _/   ");
    System.out.println("  _/_/        _/_/    _/_/_/_/    ");
    System.out.println(" _/  _/          _/  _/    _/     ");
    System.out.println("_/    _/  _/_/_/    _/    _/      ");
    System.out.println("");
    System.out.println("Welcome to Ksa's Tylenol CWE APAP intake calculator!");
    System.out.println("");
    System.out.println("Select a topic and press enter:");
    System.out.println("");
    System.out.println("1. Check if my CWE is safe");
    System.out.println("2. Tylenol solubility in water");
    System.out.println("3. Exit");
    Scanner input = new Scanner(System.in);
    double entry = input.nextDouble();
    n = 2;
    if(entry==1)
    {
        Scanner input3 = new Scanner(System.in);
        System.out.println("Enter the solution temperature before filtration in degrees Celsius:");
        double temperature = input3.nextDouble();
         if(temperature < 0)
        {
          System.out.println("Water freezes at zero...");
          System.out.println("Press Enter to exit the program.");
          Scanner input4 = new Scanner(System.in);
          String entrya = input4.nextLine();
          System.exit(0);
        }
        System.out.println("How many pills do you want to use?");
        double pills = input.nextDouble();
        if(pills < 0)
        {
          System.out.println("Stop trying to fail the program...I'm smarter lol.");
          System.out.println("Press Enter to exit the program.");
          Scanner input4 = new Scanner(System.in);
          String entrya = input4.nextLine();
          System.exit(0);
        }
        System.out.println("Enter acetaminophen content of one pill, in miligrams (mg):");
        double apap = input.nextDouble();
        if(apap < 0)
        {
          System.out.println("Stop trying to fail the program...I'm smarter lol.");
          System.out.println("Press Enter to exit the program.");
          Scanner input4 = new Scanner(System.in);
          String entrya = input4.nextLine();
          System.exit(0);
        }
        System.out.println("Enter the total water volume you plan on using, in millilitres (mL):");
        double water = input.nextDouble();
        if(water < 0)
        {
          System.out.println("Stop trying to fail the program...I'm smarter lol.");
          System.out.println("Press Enter to exit the program.");
          Scanner input4 = new Scanner(System.in);
          String entrya = input4.nextLine();
          System.exit(0);
        }
        double solubility = (0.0006*Math.pow(temperature,2) + 0.0165*temperature + 0.7221)*10;
        double intake = pills*apap;
        double intake2 = water*solubility;
        if(temperature > 50)
        {
          System.out.println("Your temperature is unsafe.");
          System.out.println("Lower the temperature below 50 degrees Celsius.");
          System.out.println("Press Enter to exit the program.");
          Scanner input4 = new Scanner(System.in);
          String entrya = input4.nextLine();
          System.exit(0);
        }
        if(pills > 50)
        {
        System.out.println("FATAL OPIATE OVERDOSE IMMINENT!");
        System.out.println("You have entered "+ pills+" pills, that's unsafe!!!");
        System.out.println("Press Enter to exit the program.");
        Scanner input5 = new Scanner(System.in);
        String entrya = input5.nextLine();
        System.exit(0);
      }
      if(pills*apap < water*solubility && pills*apap>8000)
      {
        System.out.println("FATAL APAP OVERDOSE IMMINENT!");
        System.out.println("Your APAP intake is "+ a.format(intake/1000)+ " g!");
        System.out.println("You should be using "+ 2.5*pills+" mL of water instead of "+water+" mL!");
        System.out.println("Press Enter to exit the program.");
        Scanner input6 = new Scanner(System.in);
        String entrya = input6.nextLine();
        System.exit(0);
      }
      else if(pills*apap >= water*solubility && water*solubility>8000)
      {
        System.out.println("FATAL APAP OVERDOSE IMMINENT!");
        System.out.println("Your APAP intake is "+ a.format(intake2/1000)+ " g!");
        System.out.println("You should be using "+ a.format(2.5*pills)+" mL of water instead of "+a.format(water)+" mL!");
        System.out.println("Press Enter to exit the program.");
        Scanner input7 = new Scanner(System.in);
        String entrya = input7.nextLine();
        System.exit(0);
      }
      else if(pills*apap < water*solubility && pills*apap>2000)
      {
        System.out.println("Your CWE is unsafe! Abord immediatly!");
        System.out.println("Your APAP intake is "+ a.format(intake/1000)+ " g!");
        System.out.println("You should be using "+ a.format(2.5*pills)+" mL of water instead of "+a.format(water)+" mL!");
        System.out.println("Press Enter to exit the program.");
        Scanner input8 = new Scanner(System.in);
        String entrya = input8.nextLine();
        System.exit(0);
      }
      else if(pills*apap >= water*solubility && water*solubility>2000)
      {
        System.out.println("Your CWE is unsafe! Abord immediatly!");
        System.out.println("Your APAP intake is "+ a.format(intake2/1000)+ " g!");
        System.out.println("You should be using "+ a.format(2.5*pills)+" mL of water instead of "+a.format(water)+" mL!");
        System.out.println("Press Enter to exit the program.");
        Scanner input9 = new Scanner(System.in);
        String entrya = input9.nextLine();
        System.exit(0);
      }
      else{
        System.out.println(pills*apap < water*solubility ? "Your APAP intake is "+a.format(intake/1000)+ " g. All the APAP is disolved." : " Your Tylenol intake is "+a.format(intake2/1000)+ " g. Looks safe to me 8]");
        System.out.println("Press Enter to exit the program.");
        Scanner input9 = new Scanner(System.in);
        String entrya = input9.nextLine();
        System.exit(0);
      }
    }
    else if(entry==2)
    {
      System.out.println("Enter water temperature in degrees Celsius from 0 to 100C:");
      Scanner input2 = new Scanner(System.in);
      double temperature = input2.nextDouble();
      if(temperature < 0)
        {
          System.out.println("Water freezes at zero...(Invalid value)");
          System.out.println("Press Enter to exit the program.");
          Scanner input4 = new Scanner(System.in);
          String entrya = input4.nextLine();
          System.exit(0);
        }
      else if(temperature > 100)
        {
          System.out.println("Water boils at 100C. (Invalid value)");
          System.out.println("Press Enter to exit the program.");
          Scanner input4 = new Scanner(System.in);
          String entrya = input4.nextLine();
          System.exit(0);
        }
      else{
      double solubility = 0.0006*Math.pow(temperature,2) + 0.0165*temperature + 0.7221;
      System.out.println("The solubility of Acetaminophen in water at "+temperature+" degrees Celsius is "+a.format(solubility)+"g/100mL");
      System.out.println("Press Enter to exit the program.");
      Scanner input9 = new Scanner(System.in);
      String entrya = input9.nextLine();
      System.exit(0);
      }
    }
    else{System.exit(0);}
    
  }
    catch(Exception e){
      System.out.println("");
      System.out.println("Wtf did you type???");
      System.out.println("Type again dude...");
      System.out.println("");
  }
  }while(n==1);

}
}
 
Since the program knows more than all the site reunited, I expect this to be moved in the CWE topic asap...or don't move it. Your loss. :)
 
I don't know much about code, but I read through it and I got a good idea of what it would work like; Good job!
 
thanks! :)

let me know if you find legitimate values that yield a bad answer, I tried everything and it looks ok but you never know. Here's a screenshot:

apapm.jpg

cwee.jpg
 
Last edited:
Neat!

I think that you mean "abort" rather than "abord" in the fatal APAP sections. Also, it might be neat to have different cutoffs for chronic/casual use, as the former should have a lower threshold for safe use. All in all, nicely done though.
 
thx! k I may do that when I get home. I wonder what that value would be though. It's highly debatable according to many, like, what daily tylenol intake is considered safe? I would say 100mg if it was up to me but many ppl will disagree lol
 
Last edited:
I'd probably say sub 500 mg for even casual use, but that's just me. I fried my liver with apap years ago, so I'm a bit biased. Cool idea though-- I dig it.
 
Top