QuestionQuestion

Transcribed TextTranscribed Text

Pepper's Pill Mill is a pharmaceutical company that is developing a new drug to help fight Alzheimer's disease. The drug has performed well in laboratory experiments, and the company has received approval to begin trials with people. To help make sure that the trial is unbiased, they are asking you to develop a Java program that can perform the data analysis and determine the drug's effectiveness. Each trial consists of 3 groups of individuals undergoing different treatment: 1. Control Group- No treatment. 2. Experimental Group - New Drug Administered. 3. Placebo Group - Fake Drug (sugar pills) Administered. Every individual in each group gets the same memory evaluation, and the doctor will write down a score for that individual as a number between 0 and 100. There are many patients in each group, so some simple statistics are necessary to determine the effectiveness of the treatment. DIRECTIONS Input and Output Your program should take as input: • File names for three input files (one for each group in the trial) • A file name for the output file Your program should output: • A file with the trial results Your program should ask for the names of 3 files (input files) that contain memory evaluation data for the three groups in this trial. Your program should then ask for a name for the file that will hold the trial results (the output file). All files will be located in the same directory as your program. Each input data file contains a list of integers - one on each line. The study is double-blind, so your program will not know which data file corresponds to which experimental group. Additionally, the group sizes may be different. For each input file, your program should read in the data from the file. Your program will need to calculate the average and standard deviation for that data set. Your program will also need to determine if there is a significant difference between each pair of groups in this trial. To determine if there is a significant difference between two groups in the trial, your program must compute the positive difference between the averages of the two groups. If the difference between the averages is larger than the standard deviations of both groups, then this is a significant result. For example, given the following statistics: group 1: average = 69.00, standard deviation = 18.42 group 2: average = 47.00, standard deviation = 19.92 group 3: average = 51.58, standard deviation = 19.20 There is a significant difference between group 1 and group 2, because: 69.00 - 47.00 is greater than 18.42 and 69.00 - 47.00 is greater than 19.92 However, there is not a significant difference between group 1 and group 3, because: 69.00 - 51.58 is not greater than 18.42 Your program should write the results to an output file. The results file will have two sections. The first section (Statistics) will list the name of each input file, followed by the average and then the standard deviation for that file. The second section (Results) will list the names of the two files being compared, and an indication (true or false) of whether or not the result is significant. Here is a generalized example of the output file format: Statistics: <data file 1 name>: <average 1> <standard deviation 1> <data file 2 name>: <average 2> <standard deviation 2> <data file 3 name>: <average 3> <standard deviation 3> Results: <data file 1 name> vs. <data file 2 name> : (true/false) <data file 1 name> vs. <data file 3 name> : (true/false) <data file 2 name> vs. <data file 3 name> : (true/false) Required Class In addition to the class that contains your main method, you must implement and use the following TrialGroup class in your program. This class will be used to instantiate objects that will represent each of the three groups in a trial. Each TrialGroup object will store the important information for one trial group: the name of the file containing the group data (fileName), the number of data points in that file (count), the sum of the values in that file (sum), and the sum of the squares of the values in that file (sumOfSquares). These stored values will be used to calculate the average, and the standard deviation for the group. The TrialGroup object will also be able to determine and return: the average of the values in the group (getAverage), the standard deviation of the values in the group (getStandardDeviation), and the name of the file that the values came from (getFileName). TrialGroup - fileName : String - count : int - sum : int - sumOfSquares : int + TrialGroup(fileName : String) <<constructor>> + getAverage( ) : double + getStandardDeviation( ) : double + getFileName( ) : String The constructor for this class must initialize a TrialGroup object by: 1. Storing the file name that is passed in as an argument, in the instance variable fileName. 2. Opening the file whose name is passed in as an argument (fileName) 3. Reading in the values in the file and determining the count, sum, and sum of the squares for the values in the file. 4. Storing these values in the instance variables (count, sum, sumOfSquares) The getFileName method will simply return a copy of the string stored in the instance variable fileName. The getAverage method will compute and return the average of the values in this trial group. The getStandardDeviation method will compute and return the standard deviation of the values in this trial group. Here is one way to determine the standard deviation of a set of numbers Find the following values: count - How many numbers are in the set sum - The sum of the numbers in the set sumOfSquares - The sum of the squares (n * n) of each number (n) in the set With these values, you can compute the standard deviation like this: First compute the average (sum / count) Next compute the squareOfAverage (average * average) Then compute the averageOfSquares (sumOfSquares / count) Finally compute the standard deviation: sqrt(averageOfSquares - squareOfAverage) You may add any attributes (variables) or operations (methods) that you wish to the TrialGroup class. However, you may not delete or change the details of any of the attributes and operations in the given class diagram above. Test Data For your testing convenience, Pepper has have provided 3 sets of test files of dummy data, and example output files based on the test files. Download these text files from the link below. Your program should use good programming practice and structure, including the definition and use of at least one class.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;


public class PeppersPillMill {
    /**
    * In addition to the class that contains your main method, you must
    * implement and use the following TrialGroup class in your program.
    *
    * @param args
    */
    public static void main(String[] args) {
       // Your program should ask for the names of 3 files (input files)
       // that contain memory evaluation data for the three groups
       // in this trial.
       Scanner keyboard = new Scanner(System.in);
       String fileName;

       System.out.print("Enter the first input file: ");
       fileName = keyboard.next();
       TrialGroup group1 = new TrialGroup(fileName);

       System.out.print("Enter the sedond input file: ");
       fileName = keyboard.next();
       TrialGroup group2 = new TrialGroup(fileName);

       System.out.print("Enter the third input file: ");
       fileName = keyboard.next();
       TrialGroup group3 = new TrialGroup(fileName);

       // Your program should then ask for a name for the file that will
       // hold the trial results (the output file).
       // All files will be located in the same directory as your program. 
       System.out.print("Enter the output file: ");
       fileName = keyboard.next();

       try {
            FileWriter fw = new FileWriter(fileName);

            /**
             * The results file will have two sections. The first section
             * (Statistics) will list the name of each input file, followed by
             * the average and then the standard deviation for that file
             */
            fw.write("Statistics:" + System.lineSeparator());
            fw.write(group1.getFileName() + ": "
                   + group1.getAverage() + " "
                   + group1.getStandardDeviation()
                   + System.lineSeparator());
            fw.write(group2.getFileName() + ": "
                   + group2.getAverage() + " "
                   + group2.getStandardDeviation()
                   + System.lineSeparator());
            fw.write(group3.getFileName() + ": "
                   + group3.getAverage() + " "
                   + group3.getStandardDeviation()
                   + System.lineSeparator());

            /**
             * The second section (Results) will list the names of the two files
             * being compared, and an indication (true or false) of whether or
             * not the result is significant.
             */
            fw.write("Results:" + System.lineSeparator());
            
            // first pair
            fw.write(group1.getFileName() + " vs. "
                   + group2.getFileName() + " : ");
            if (Math.abs(group1.getAverage() - group2.getAverage())
                   <= group1.getStandardDeviation()
                   || Math.abs(group1.getAverage() - group2.getAverage())
                   <= group2.getStandardDeviation()) {
                fw.write("false");
            } else {...

By purchasing this solution you'll be able to access the following files:
Solution.java.

$20.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats