Medicine Prescriptions Java
Medicine Prescriptions Java
Medicine Prescriptions Java
*;
public class CIS129_WhitneyHenderson_Lab3v2{
static Scanner keyboard = new Scanner(System.in);
static final int EXIT = 5;
static final String [][] MEDICINE = {
{"Abilify- ", "an antipsychotic drug"},
{"Ambien- ", "to treat insomnia"},
{"Amoxi- ", "an antibiotic"},
{"Aspirin- ", "a pain reliever"},
{"Crestor- ", "a cholesterol-lowering statin drug"},
{"Placebotec- ","to treat hypochondriacs"},
{"Xanax- ", "to treat anxiety disorders"},
{"Norvasc- ", "a high blood pressure drug"},
{"Penicillin- ","an antibiotic"},
{"Plavix- ", "a blood thinner"},
{"Prilosec- ", "to treat reflux disease"},
{"Wellbe- ", "an antidepressant"},
{"Nexium- ", "an antacid drug"},
{"Zoloft- ", "an antidepressant"}
};
public static void main (String [] args){
do{
boolean [] medsPrescribed = new boolean [MEDICINE.length];
int userInput;
String yourName;
displayWelcome();
menuOptions();
//makes sure that the first value entered is 1
userInput = getValidMenu("Please enter a menu option");
while (firstInput(userInput)){
System.out.println("You must sign in as a doctor first");
menuOptions();
userInput = getValidMenu("Please enter a menu option");
}// end while
yourName = IR.getString("Please enter your name Doc");
//makes ure that you are entering the correct values and searches the menu
menuOptionsDoc(yourName);
userInput = getValidMenu("Please enter a menu option");
searchMenu(userInput, medsPrescribed);
while(userInput != EXIT){
System.out.println("\n");
menuOptionsDoc(yourName);
userInput = getValidMenu("Please enter a menu option");
searchMenu(userInput, medsPrescribed);
}//end while
System.out.println("Goodbye");
System.out.println("*************************************************************
***************************");
System.out.println("Welcome to the patient portal, a one stop shop to get your job done!");
System.out.println("Prescribe precriptions, check prescription history, and even reset the
prescription history");
System.out.println("Here are the menu options please sign in as a doctor first to get things
started!");
System.out.println("*************************************************************
***************************");
}
public static void menuOptions(){
System.out.println("*********************************************");
System.out.println("Welcome to Your Patient's Prescription History");
System.out.println("*********************************************");
System.out.println("Menu Options");
System.out.println("1. Sign in as the doctor");
System.out.println("2. Display prescription history");
System.out.println("3. Prescribe medicine");
System.out.println("4. Reset prescription history");
System.out.println("5. Exit the program");
}//end menu options 1
//search menu module. searches the menu when the user inputs
public static void searchMenu(int userInput, boolean [] medsPrescribed){
if(userInput == 2){
optionTwo(userInput, medsPrescribed);
}else{
if(userInput == 3){
userInput = optionThree(userInput);
if((IR.getYorN("Are you sure you would like to prescribe this medicine? (enter yes or
no)"))){
prescribe(userInput, medsPrescribed);
}
}else{
if(userInput == 4){
if((IR.getYorN("Are you sure you want to erase the precription history? (enter yes or
no)"))){
optionFour(userInput, medsPrescribed);
}
}else{
if(userInput == EXIT){
System.out.println(" ");
}
}
}
}
}// end searchMenu
//
//
//
//option three for entering the medicine they would like to prescribe
public static int optionThree(int userInput){
userInput = IR.getInteger("Please enter a menu option (enter 0 to see menu)");
if(userInput == 0){
print2Darray(MEDICINE);
}
while(validMenu(userInput)){
System.out.println("Enter one of the menu options please");
userInput = IR.getInteger("Please enter a menu option (enter 0 to see menu)");
if(userInput == 0){
print2Darray(MEDICINE);
}
}
return userInput;
}// end optionThree
public static void optionTwo(int userInput, boolean [] medsPrescribed){
System.out.println("************************************");
System.out.println("Your Patient's Prescription History");
System.out.println("************************************");
for (int i = 0; i < MEDICINE.length; i++){
System.out.print("Medicine #"+(i+1)+":");
for (int j = 0; j < MEDICINE[i].length; j++){
System.out.print(MEDICINE[i][j]);
}
if(medsPrescribed[i]){
System.out.print("-already prescribed");
}
System.out.println();
}
System.out.println("\n");
}