Ksa
Ex-Bluelighter
I made a program that evaluates dissolved acetaminophen quantities and the resulting toxicity upon ingestion. The program also suggests the lowest water amount that can be used for a certain amount of pills that will result in a liquid mixture. The program can tell if the pills dissolve completely or if filtration is needed and many other features.
Can a scientist or engineer confirm that the program is safe for the use, in any circumstances, and that the output information is 100% accurate for any possible user input?
http://www.megaupload.com/?d=O0Q00REF
The code is too long to fit on one page I'm afraid so I'll use 2 pages.
Can a scientist or engineer confirm that the program is safe for the use, in any circumstances, and that the output information is 100% accurate for any possible user input?
http://www.megaupload.com/?d=O0Q00REF
The code is too long to fit on one page I'm afraid so I'll use 2 pages.
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(date.toString()+"\n");
System.out.println("Welcome to Ksa's disolved acetaminophen calculator!\n");
System.out.println("WARNING: This program outputs toxicity information for acetaminophen only.");
System.out.println(" Daily use of acetaminophen can be hazardous regardless of output.");
System.out.println(" This helps users who have trouble swallowing the pills make safe ");
System.out.println(" acetaminophen solutions. Program intended for proper use only. ");
System.out.println("");
System.out.println("Select a topic and press enter:");
System.out.println("");
System.out.println("1. Check if a solution has safe amounts of disolved acetaminophen.");
System.out.println("2. Give me the acetaminophen water solubility value for a certain temperature.");
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("");
System.out.println("Enter solution temperature in degrees Celsius before filtration:");
double temperature = input3.nextDouble();
if(temperature < 0)
{
System.out.println("");
System.out.println("Water freezes at zero degrees celsius.(Invalid value)");
System.out.println("");
System.out.println("Press Enter to abord.");
Scanner input4 = new Scanner(System.in);
String entrya = input4.nextLine();
System.exit(0);
}
System.out.println("");
System.out.println("Enter amount of pills:");
double pills = input.nextDouble();
if(pills < 0)
{
System.out.println("");
System.out.println("Invalid entry.");
System.out.println("");
System.out.println("Press Enter to abord.");
Scanner input4 = new Scanner(System.in);
String entrya = input4.nextLine();
System.exit(0);
}
System.out.println("");
System.out.println("Enter acetaminophen content of one pill, in miligrams (mg):");
double apap = input.nextDouble();
if(apap < 0)
{
System.out.println("");
System.out.println("Invalid entry.");
System.out.println("");
System.out.println("Press Enter to abord.");
Scanner input4 = new Scanner(System.in);
String entrya = input4.nextLine();
System.exit(0);
}
System.out.println("");
System.out.println("Enter the total water volume, in millilitres (mL):");
double water = input.nextDouble();
if(water < 0)
{
System.out.println("");
System.out.println("Invalid entry.");
System.out.println("");
System.out.println("Press Enter to abord.");
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 > 35)
{
System.out.println("");
System.out.println("The temperature is unsafe, resulting in high amounts of disolved acetaminophen.\nPlease lower the temperature below 35 degrees Celsius.");
System.out.println("");
System.out.println("Press Enter to abord.");
Scanner input4 = new Scanner(System.in);
String entrya = input4.nextLine();
System.exit(0);
}
if(pills > 50)
{
System.out.println("");
System.out.println("You have entered "+ pills+" pills. That may be unsafe for other reasons.");
System.out.println("");
System.out.println("Press Enter to abord.");
Scanner input5 = new Scanner(System.in);
String entrya = input5.nextLine();
System.exit(0);
}
if(apap > 2000)
{
System.out.println("");
System.out.println("You have entered "+ apap+" mg acetaminophen per pill. \nThat amount is non FDA approved and is considered dangerous.");
System.out.println("");
System.out.println("Press Enter to abord.");
Scanner input23 = new Scanner(System.in);
String entrya = input23.nextLine();
System.exit(0);
}
if(water > 500)
{
System.out.println("");
System.out.println(water + " ml of water is unsafe.(above 500ml treshold).");
System.out.println("");
System.out.println("Press Enter to abord.");
Scanner input41 = new Scanner(System.in);
String entrya = input41.nextLine();
System.exit(0);
}
