Questions
What is the relationship between the amount of time statistics students study per week and their...

What is the relationship between the amount of time statistics students study per week and their final exam scores? The results of the survey are shown below.

Time 16 13 9 14 14 16 0 6
Score 98 82 91 100 86 95 62 83
  1. Find the correlation coefficient: r=r=    Round to 2 decimal places.
  2. The null and alternative hypotheses for correlation are:
    H0:H0: ? ρ μ r  == 0
    H1:H1: ? ρ μ r   ≠≠ 0
    The p-value is:    (Round to four decimal places)
  3. Use a level of significance of α=0.05α=0.05 to state the conclusion of the hypothesis test in the context of the study.
    • There is statistically significant evidence to conclude that a student who spends more time studying will score higher on the final exam than a student who spends less time studying.
    • There is statistically insignificant evidence to conclude that there is a correlation between the time spent studying and the score on the final exam. Thus, the use of the regression line is not appropriate.
    • There is statistically significant evidence to conclude that there is a correlation between the time spent studying and the score on the final exam. Thus, the regression line is useful.
    • There is statistically insignificant evidence to conclude that a student who spends more time studying will score higher on the final exam than a student who spends less time studying.
  4. r2r2 =  (Round to two decimal places)
  5. Interpret r2r2 :
    • 72% of all students will receive the average score on the final exam.
    • There is a large variation in the final exam scores that students receive, but if you only look at students who spend a fixed amount of time studying per week, this variation on average is reduced by 72%.
    • There is a 72% chance that the regression line will be a good predictor for the final exam score based on the time spent studying.
    • Given any group that spends a fixed amount of time studying per week, 72% of all of those students will receive the predicted score on the final exam.
  6. The equation of the linear regression line is:   
    ˆyy^ =  + xx   (Please show your answers to two decimal places)
  7. Use the model to predict the final exam score for a student who spends 10 hours per week studying.
    Final exam score =  (Please round your answer to the nearest whole number.)
  8. Interpret the slope of the regression line in the context of the question:
    • The slope has no practical meaning since you cannot predict what any individual student will score on the final.
    • For every additional hour per week students spend studying, they tend to score on averge 1.84 higher on the final exam.
    • As x goes up, y goes up.

  9. Interpret the y-intercept in the context of the question:
    • If a student does not study at all, then that student will score 67 on the final exam.
    • The y-intercept has no practical meaning for this study.
    • The average final exam score is predicted to be 67.
    • The best prediction for a student who doesn't study at all is that the student will score 67 on the final exam.

In: Statistics and Probability

The average GPA of a random sample of 18 college students who take evening classes was...

The average GPA of a random sample of 18 college students who take evening classes was calculated to be 2.94 with a standard deviation of 0.04. The average GPA of a random sample of 12 college students who take daytime classes was calculated to be 2.89 with a standard deviation of 0.05. Test the claim that the mean GPA of night students is larger than the mean GPA of day students at the .01 significance level.

Claim: Select an answer μ 1 < μ 2 μ 1 ≤ μ 2 p 1 = p 2 p 1≠p 2 p 1 < p 2 p 1 > p 2 p 1 ≤ p 2 μ 1 = μ 2 p 1 ≥ p 2 μ 1 > μ 2 μ 1≠μ 2 μ 1 ≥ μ 2  which corresponds to Select an answer H1: μ 1 < μ 2 H0: μ 1 = μ 2 H1: μ 1≠μ 2 H1: p 1≠p 2 H0: μ 1 ≤ μ 2 H1: p 1 > p 2 H1: μ 1 > μ 2 H0: p 1 ≤ p 2 H1: p 1 < p 2 H0: μ 1≠μ 2

Opposite: Select an answer p 1 < p 2 p 1 ≤ p 2 μ 1 ≥ μ 2 μ 1 < μ 2 μ 1 = μ 2 μ 1 > μ 2 μ 1 ≤ μ 2 p 1 ≥ p 2 p 1 > p 2 μ 1≠μ 2 p 1 = p 2 p 1≠p 2  which corresponds to Select an answer H0: p 1≠p 2 H1: μ 1 > μ 2 H0: μ 1 ≤ μ 2 H1: μ 1≠μ 2 H1: p 1 ≥ p 2 H0: p 1 > p 2 H1: p 1 <= p 2 H1: p 1 = p 2 H0: μ 1 = μ 2 H1: μ 1 < μ 2 H0: μ 1≠μ 2


The test is: Select an answer two-tailed right-tailed left-tailed

The test statistic is: tt = Select an answer 2.9 2.415 2.546 3.007 3.181

The critical value is: tαtα= Select an answer  2.384  2.453  2.718  2.919  2.563

Based on this we: Select an answer Cannot determine anything Accept the null hypothesis Fail to reject the null hypothesis Reject the null hypothesis

Conclusion There Select an answer does not does  appear to be enough evidence to support the claim that the mean GPA of night students is larger than the mean GPA of day students.

In: Statistics and Probability

Is it true that students tend to gain weight during their first year in college? Cornell...

Is it true that students tend to gain weight during their first year in college? Cornell Professor of Nutrition David Levitsky recruited students from two large sections of an introductory health course. Although they were volunteers, they appeared to match the rest of the freshman class in terms of demographic variables such as sex and ethnicity. The students were weighed during the first week of the semester, then again 12 weeks later at the end of the semester (weights are in pounds).

subject initial weight terminal weight
1 171 168
2 110 111
3 134 136
4 115 119
5 150 155
6 104 106
7 142 148
8 120 124
9 144 148
10 156 154
11 114 114
12 121 123
13 122 126
14 120 115
15 115 118
16 110 113
17 142 146
18 127 127
19 102 105
20 125 125
21 157 158
22 119 126
23 113 114
24 120 128
25 135 139
26 148 150
27 110 112
28 160 163
29 220 224
30 132 133
31 145 147
32 141 141
33 158 160
34 135 134
35 148 150
36 164 165
37 137 138
38 198 201
39 122 124
40 146 146
41 150 151
42 187 192
43 94 96
44 105 105
45 127 130
46 142 144
47 140 143
48 107 107
49 104 105
50 111 112
51 160 162
52 134 134
53 151 151
54 127 130
55 106 108
56 185 188
57 125 128
58 125 126
59 155 158
60 118 120
61 149 150
62 149 149
63 122 121
64 155 158
65 160 161
66 115 119
67 167 170
68 131 131

1) Construct a dotplot depicting the distribution of the change in the students’ weights from the beginning of the semester to the end of the semester.

2)Suppose Professor Levitsky wishes to use the data he collected from his students in a research paper. He wants to prove freshman students tend to gain weight during their first semester in college.

Frame this research question as a hypothesis testing problem. Identify the parameter being tested, the null value, and explicitly write out the null and alternative hypothesis in terms of the parameter and null value.

In: Statistics and Probability

1) Are unnecessary c-sections putting moms and babies health at risk? The procedure is a major...

1) Are unnecessary c-sections putting moms and babies health at risk? The procedure is a major surgery which increases risks for the baby (breathing problems and surgical injuries) and for the mother (infection, hemorrhaging, and risks to future pregnancies). According to the Center for disease control and prevention, about 32.2% of all babies born in the U.S. are born via c-section. The World Health Organization recommends that the US reduce this rate by 10%.

Some states have already been working towards this. Suspecting that certain states have lower rates than 32.2%, researchers randomly select 1200 babies from Wisconsin and find that 20.8% of the sampled babies were born via c-section.

Let p be the proportion of all babies in the U.S. that are born via c-section. Give the null and alternative hypotheses for this research question.

1) H0: p = .322

Ha: p < .322

2) H0: p = .322

Ha: p ≠ .322

3) H0: p = .208

Ha: p ≠ .208

4) H0: p < .322

Ha: p = .322

5) H0: p = .322

Ha: p > .322

2) A quality control engineer at a potato chip company tests the bag filling machine by weighing bags of potato chips. Not every bag contains exactly the same weight. But if more than 15% of bags are over-filled then they stop production to fix the machine.

They define over-filled to be more than 1 ounce above the weight on the package. The engineer weighs 100 bags and finds that 31 of them are over-filled.

He plans to test the hypotheses: H0: p = 0.15 versus Ha: p > 0.15 (where p is the true proportion of overfilled bags).

What is the test statistic?

1) 4.48

2) 3.46

3) -3.46

3) According to a Pew Research Center, in May 2011, 35% of all American adults had a smartphone (one which the user can use to read email and surf the Internet). A communications professor at a university believes this percentage is higher among community college students.

She selects 300 community college students at random and finds that 126 of them have a smartphone. In testing the hypotheses: H0: p = 0.35 versus Ha: p > 0.35, she calculates the test statistic as Z = 2.54.

Use the Normal Table to help answer the p-value part of this question.

1) There is enough evidence to show that more than 35% of community college students own a smartphone (P-value = 0.0055).

2) There is not enough evidence to show that more than 35% of community college students own a smartphone (P-value = 0.9945).

3) There is not enough evidence to show that more than 35% of community college students own a smartphone (P-value = 0.011).

4) There is not enough evidence to show that more than 35% of community college students own a smartphone (P-value = 0.0055).

In: Statistics and Probability

What is the relationship between the amount of time statistics students study per week and their...

What is the relationship between the amount of time statistics students study per week and their test scores? The results of the survey are shown below. Time 2 5 9 1 4 11 13 11 13 Score 60 61 70 49 72 84 76 80 83 Find the correlation coefficient: r = Round to 2 decimal places. The null and alternative hypotheses for correlation are: H 0 : = 0 H 1 : ≠ 0 The p-value is: (Round to four decimal places) Use a level of significance of α = 0.05 to state the conclusion of the hypothesis test in the context of the study. There is statistically significant evidence to conclude that a student who spends more time studying will score higher on the test than a student who spends less time studying. There is statistically insignificant evidence to conclude that there is a correlation between the time spent studying and the score on the test. Thus, the use of the regression line is not appropriate. There is statistically insignificant evidence to conclude that a student who spends more time studying will score higher on the test than a student who spends less time studying. There is statistically significant evidence to conclude that there is a correlation between the time spent studying and the score on the test. Thus, the regression line is useful. r 2 = (Round to two decimal places) Interpret r 2 : There is a 78% chance that the regression line will be a good predictor for the test score based on the time spent studying. Given any group that spends a fixed amount of time studying per week, 78% of all of those students will receive the predicted score on the test. There is a large variation in the test scores that students receive, but if you only look at students who spend a fixed amount of time studying per week, this variation on average is reduced by 78%. 78% of all students will receive the average score on the test. The equation of the linear regression line is: ˆ y = + x (Please show your answers to two decimal places) Use the model to predict the test score for a student who spends 9 hours per week studying. Test score = (Please round your answer to the nearest whole number.) Interpret the slope of the regression line in the context of the question: For every additional hour per week students spend studying, they tend to score on average 2.22 higher on the test. The slope has no practical meaning since you cannot predict what any individual student will score on the test. As x goes up, y goes up. Interpret the y-intercept in the context of the question: The average test score is predicted to be 54. The best prediction for a student who doesn't study at all is that the student will score 54 on the test. If a student does not study at all, then that student will score 54 on the test. The y-intercept has no practical meaning for this study.

In: Statistics and Probability

Question 6 (1 point) According to a survey of 786 small business participants chosen at random...

Question 6 (1 point)

According to a survey of 786 small business participants chosen at random in the Constant Contact Small Biz Council in May of 2013, 431 of the respondents say it is harder to run a small business now than it was 5 years ago. When estimating the population proportion, what is the 90% confidence interval estimating the proportion of businesses who believe it is harder to run a business now than 5 years ago?

Question 6 options:

1)

( 0.5306 , 0.5661 )

2)

( 0.42246 , 0.48085 )

3)

( 0.5256 , 0.57109 )

4)

( 0.51915 , 0.57754 )

5)

( -0.51915 , 0.57754 )

Question 7 (1 point)

A U.S. census bureau pollster noted that in 379 random households surveyed, 218 occupants owned their own home. What is the 99% confidence interval estimate of the proportion of American households who own their own home?

Question 7 options:

1)

( 0.51613 , 0.63427 )

2)

( 0.54981 , 0.60059 )

3)

( 0.50979 , 0.6406 )

4)

( -0.50979 , 0.6406 )

5)

( 0.3594 , 0.49021 )

Question 8 (1 point)

You are watching a nightly news broadcast on CNN and the reporter says that a 90% confidence interval for the proportion of Americans who supported going to war in Iraq was ( 0.4073 , 0.4635 ). You also note that the footnote says this is based on a random sample performed by Gallup with 836 respondents. What is the correct interpretation of this confidence interval?

Question 8 options:

1)

We cannot determine the proper interpretation of this interval.

2)

We are 90% confident that the proportion of all Americans who supported going to war in Iraq is between 0.4073 and 0.4635.

3)

We are 90% confident that the proportion of all Americans surveyed who supported going to war in Iraq is between 0.4073 and 0.4635.

4)

We are 90% confident that of the 836 respondents, between 0.4073 and 0.4635 of them supported the decision to go to war.

5)

We are certain that 90% of Americans will be between 0.4073 and 0.4635.

Question 9 (1 point)

Based on past data, the Student Recreation Center knew that the proportion of students who prefer exercising outside over exercising in a gym was 0.836. To update their records, the SRC conducted a survey. Out of 85 students surveyed, 71 indicated that they preferred outdoor exercise over exercising in a gym. The 99% confidence interval is ( 0.7317 , 0.9389 ). Which of the following statements is the best conclusion?

Question 9 options:

1)

The proportion of students who have changed their exercise habits from 0.836 is 99%.

2)

We can not claim that the proportion of students who prefer outdoor exercise differs from 0.836.

3)

We can conclude that the proportion of students who prefer outdoor exercise is larger than 0.836.

4)

We can claim that the proportion of students who prefer outdoor exercise is smaller than 0.836.

5)

The confidence interval does not provide enough information to form a conclusion.

In: Statistics and Probability

4) A magazine reported the results of a survey in which readers were asked to send...

4) A magazine reported the results of a survey in which readers were asked to send their responses to several questions regarding good eating. DataSet for question 4,5,6 is the reported results to the question, How often do you eat chocolate? Based on the data answer the following questions.

a) Were the responses to this survey obtained using voluntary sampling technique? Explain

b) What type of bias may be present in the response?

c) is 13% a reasonable estimate of the proportion of all Americans who eat chocolate frequently? Explain.

5) A magazine reported the results of a survey in which readers were asked to send in their responses to several questions regarding anger. DataSet2 for Question 5 shows the reported results to the question, How long do you usually stay angry? Answer the following questions based on the data.

a) Were the responses to this survey obtained using voluntary sampling technique?

b) What type of bias may be present in the response?

c) Is 22% a reasonable estimate of the proportion of all Americans who hold a grudge indefinitely? Explain.

6) Students in marketing class have been asked to conduct a survey to determine whether or not there is demand for an insurance program at a local college. The Students decided to randomly select students from the local college and mail them a questionnare regarding the insurance program. Of the 150 questionnaire that were mailed, 50 students responded to the following survey item: Pick the Category which best describes your interest in an insurance program. DataSet2 for question 6 shows the responses. Use this data to answer the following question.

a)What type of bias may be present in the response?

b) is 50% a reasonable estimate of the proportion of all students who would be very interested in an insurance program at a local college? Explain.

c) is 50% a reasonable estimate of the proportion of all business majors who would be very interested in an insurance program at a local college? Explain.

d) What strategies do you think the marketing students could have used in order to get a less biased response to their survey?

e) Suppose the program was created and only a few people registered. How could the survey question have been reworded to better predict the actual enrollment?

DATA SET FOR QUESTION 4, 5 AND 6

Table for Question 4 – Survey Responses

Category % of Responses

Frequently 13

Occasionally 45

Seldom 37

Never 5

Table for Question 5 – Survey Responses

Category % of Responses

A few hours or less 48

A day 12

Several days 9

A month 1

I hold a grudge indefinitely 22

It depends on the situation 8

Table for Question 6 – Survey Responses
Category % of Responses
Very Interested 50
Somewhat Interested 15
Interested 10
Not Very Interested 5
Not At All Interested 20

In: Math

Writing Assignment #1 Instructions The following assignment should be typed and printed or handwritten and turned...

Writing Assignment #1 Instructions
The following assignment should be typed and printed or handwritten and turned in to the CA office in room​ 201 TMCB.​ If there is no one in the CA Office, you can slip your assignment through the slot in the door.
You must follow the instructions below or you will not receive credit.​ You can turn in the assignment up until 5:00 PM on the due date.
Important Notices: If you do not staple multiple pages, you may lose points. If you do not put your section number on the paper, you may lose points. As shown below, please fold your paper lengthwise and on the outside write (a) your name, (b) Stat 121, (c) your section number, and (d) the assignment number. (An example is available outside the CA Office.)
The situation is as follows:
Rent and other associated housing costs, such as utilities, are an important part of the estimated costs of attendance at college. A group of researchers at the BYU Off-Campus Housing department want to estimate the mean monthly rent that unmarried BYU students paid during Winter 2019. During March 2019, they randomly sampled 366 BYU students and found that on average, students paid $348 for rent with a standard deviation of $76. The plot of the sample data showed no extreme skewness or outliers.

Calculate a 98% confidence interval estimate for the mean monthly rent of all unmarried BYU students in Winter 2019.
STATE
What is a 98% confidence interval estimate for the mean monthly rent of all unmarried BYU students in Winter 2019?
PLAN
1. State the name of the appropriate estimation procedure. ​(2pts)
2. Describe the parameter of interest in the context of the problem. ​(2pts)
SOLVE
1. Name the conditions for the procedure. ​(2pts)
2. Explain how the above conditions are met. ​(2pts)
3. Write down the confidence level and the t* critical value. ​(2pts)
4. Calculate the margin of error for the interval to ​two decimal places​. ​Show your work. ​(2pts)
5. ​Calculate the confidence interval ​to two decimal places​ and state it ​in interval form​. ​(2pts)
CONCLUDE
Interpret your confidence interval in context. Do this by including these three parts in your conclusion ​(3 pts)​:
● Level of confidence​ (1pt)
● Parameter of interest in context ​(1 pt)
● The interval estimate ​(1 pt)
FURTHER ANALYSIS
1. How would selecting a 95% level of confidence change the size of the calculated confidence interval? (1pt). Explain or justify your answer by recalculating (1pt) .

2. At a 95% level of confidence, what sample size would be needed to estimate the parameter of interest to within a margin of error of ± $25? Use σ = $76. ​(2pts)
3. Suppose that a second random sample of unmarried BYU students was conducted during March 2019. Using this data, the confidence interval was calculated to be ​($342.67, $349.35)​. ​Rounded to two decimal places​, what is the margin of error for this confidence interval? Show your work. (1pt)

In: Math

USE ORACLE - SQL List the name and salary of employees who work for division 3....

USE ORACLE - SQL

  1. List the name and salary of employees who work for division 3.
  2. List the name of project whose budget is between 5000-7000
  3. List the total number of employee whose initial of name is 's'. (hint, using LIKE operator and wildcard character)
  4. List the total number of employee whose initial of name is NOT 's' for each division, including division ID
  5. List the total project budget for each division, including division ID.
  6. List the ID of the division that has two or more projects with budget over $6000.
  7. List the ID of division that sponsors project "Web development", List the project budget too.
  8. List the total number of employee whose salary is above $40000 for each division, list division ID.
  9. List the total number of project and total budget for each division, show division ID
  10. List the ID of employee that worked on more than three projects.
  11. List the ID of each division with its highest salary..
  12. List the total number of project each employee works on, including employee's ID and total hours an employee spent on project.
  13. List the total number of employees who work on project 1.
  14. List names that are shared by more than one employee and list the number of employees who share that name.
  15. List the total number of employee and total salary for each division, including division name (hint: use JOIN operation, read the text for join operation)

My table is below:

drop table workon;
drop table employee;
drop table project;
drop table division;
create table division
(did integer,
dname varchar (25),
managerID integer,
constraint division_did_pk primary key (did) );

create table employee
(empID integer,
name varchar(30),
alary float,
id integer,
constraint employee_empid_pk primary key (empid),
constraint employee_did_fk foreign key (did) references division(did)
);
create table project
(pid integer,
pname varchar(25),
budget float,
did integer,
onstraint project_pid_pk primary key (pid),
constraint project_did_fk foreign key (did) references division(did)
);
create table workon
(pid integer,
empID integer,
hours integer,
constraint workon_pk primary key
(pid, empID)
);
/* loading the data into the database */
insert into division
Values (1,'engineering', 2);
insert into division
values (2,'marketing', 1);
insert into division
values (3,'human resource', 3);
insert into division
values (4,'Research and development', 5);
insert into division
values (5,'accounting', 4);

insert into project
values (1, 'DB development', 8000, 2);
insert into project
values (2, 'network development', 6000, 2);
insert into project
values (3, 'Web development', 5000, 3);
insert into project
values (4, 'Wireless development', 5000, 1);
insert into project
values (5, 'security system', 6000, 4);
insert into project
values (6, 'system development', 7000, 1);


insert into employee
values (1,'kevin', 32000,2);
insert into employee
values (2,'joan', 42000,1);
insert into employee
values (3,'brian', 37000,3);
insert into employee
values (4,'larry', 82000,5);
insert into employee
values (5,'harry', 92000,4);
insert into employee
values (6,'peter', 45000,2);
insert into employee
values (7,'peter', 68000,3);
insert into employee
values (8,'smith', 39000,4);
insert into employee
values (9,'chen', 71000,1);
insert into employee
values (10,'kim', 46000,5);
insert into employee
values (11,'smith', 46000,1);
insert into employee
values (12,'joan', 48000,1);
insert into employee
values (13,'kim', 49000,2);
insert into employee
values (14,'austin', 46000,1);
insert into employee
values (15,'sam', 52000,3);

insert into workon
values (3,1,30);
insert into workon
values (2,3,40);
insert into workon
values (5,4,30);
insert into workon
values (6,6,60);
insert into workon
values (4,3,70);
insert into workon
values (2,4,45);
insert into workon
values (5,3,90);
insert into workon
values (3,3,100);
insert into workon
values (6,8,30);
insert into workon
values (4,4,30);
insert into workon
values (5,8,30);
insert into workon
values (6,7,30);
insert into workon
values (6,9,40);
insert into workon
values (5,9,50);
insert into workon
values (4,6,45);
insert into workon
values (2,7,30);
insert into workon
values (2,8,30);
insert into workon
values (2,9,30);
insert into workon
values (1,9,30);
insert into workon
values (1,8,30);
insert into workon
values (1,7,30);
insert into workon
values (1,5,30);
insert into workon
values (1,6,30);
insert into workon
values (2,6,30);
insert into workon
values (2,12,30);
insert into workon
values (3,13,30);
insert into workon
values (4,14,20);
insert into workon
values (4,15,40);

In: Computer Science

Modify listarr.java program by adding the following 2 methods: public void insertsorted(x); // Inert x in...

Modify listarr.java program by adding the following 2 methods:

public void insertsorted(x); // Inert x in a sorted list.

protected int binsearch(x); // Binary search for x

Assume you have a data file p1.txt with the following contents:

8    

4 15 23 12 36 5 36 42

3

5 14 36

and your main program is in p1.java file.

To compile: javac p1.java

To execute: java p1 < any data file name say p1.txt

Your output should be formatted (i.e. using %4d for print) as follow:

Your name:……………………………. Student ID:…………………………

The 8 inserted data are as follow:

4 5 12 15 23 36 36 42

Searching for 3 data in the sorted list.

5: is found!

14: Ooops is not in the list?

36: is found!

Your main method should be as follow:

public static void main(String args[]) {

int j, n, m, k, x;

try{

          Scanner inf = new Scanner(System.in);                 

          n = inf.nextInt();// read No. of data to read

         

          // Create a List of type Integer of size n

          listarr Lint = new listarr(n);      

         

          // Read n element and insert in a sorted listposition randomly in the list

          for(j = 1; j <= n; j++){

                    x = inf.nextInt(); // read element

                    Lint.insertsorted (x);

          }

         

          System.out.printf(“The %d inserted data are as follow:”, n);

          System.out.print(Lint.toString());

          // read No. of data to search

          m = inf.nextInt();

          for(j = 1; j <= m; j++){

                    x = inf.nextInt(); // read data to search

                    k = Lint.binsearch(x);

                    if(k??? //complete it

          }

          inf.close();

} catch (Exception e) {prt("Exception " + e + "\n");}

}// end main method      

//   listarr.java

// Array implementation of list in JAVA
import java.util.*;
//*************** Class Definition *********************************
/**
* Implementation of the ADT List using a fixed-length array.
* Exception is thrown:
* if insert operation is attempted when List is full.
* if delete operation is attempted when List is empty.
* if position of insert or delete is out of range.
*/
   public class listarr implements list{
       // class Variables
       protected int capacity, last;
       protected T arr[];   

       listarr(int n){ // List Constructor
           last = 0;
           capacity = n;
           //Allocate Space            
          arr = (T[]) new Object[n+1];
          prt("\n List size = " + n);
       }

        public boolean isEmpty(){return (last == 0);}
        public int   length(){return last;}
       public boolean isFull() {return (last == capacity);}
       public static void prt(String s){System.out.print(s);}

       // insert x at position p (valid p's 1 <= p <= last+1 && last != capacity)      
       public void insert(T x, int p) throws invalidinsertion {
           prt("\nInsert " + x + " at position " + p);
       if (isFull() || p < 1 || p > last + 1)throw new invalidinsertion(p);
           // Shift from position p to right
           for (int i = last ; i >= p ; i--) arr[i+1] = arr[i];
           arr[p] = x; last++;
       }

       // delete element at position p (1...last)      
       public void delete(int p)throws invaliddeletion {
           prt("\nDelete " + p + "th element, ");
           if ( isEmpty() || p < 1 || p > last) throw new invaliddeletion(p);
           // Shift from position p + 1 to left
           for (int i = p ; i < last ; i++) arr[i] = arr[i+1];
           last --;
       }

       public String toString() {
           String s = "[";
       for (int i = 1; i <= last; i++) s += ", " + arr[i] ;
return s + "]";
        }       

       public static void main(String args[]) {
           int j, p, n, x, MaxNum = 5;
           Random rand = new Random();

           n = rand.nextInt(MaxNum) + 1;   // generate n randomly      

           // Create a List of type Integer of size n
           listarr Lint = new listarr(n);          

           // Generate n element and position randomly and insert in the list
           for(j = 1; j <= n; j++){
               p = rand.nextInt(n); // generate position
               x = rand.nextInt(MaxNum * 4); // generate element

               try {
                   Lint.insert(x,p);
               } catch (Exception e) {prt("Exception " + e + "\n");}
           }          

           prt("\nList: " + Lint.toString() + "\n"); // print list          

           // Delete n element from list randomly and print list
           for(j = 1; j <= n; j++){
               p = rand.nextInt(n); // generate position to delete
               try {
                   Lint.delete(p);
                   prt("\nList: " + Lint.toString() + "\n");
               } catch (Exception e) {prt("Exception " + e + "\n");}
           }

           // Create a List of type String
           n = rand.nextInt(MaxNum) + 1;   // generate n randomly      
           listarr Lstr = new listarr(n);
           try {
               Lstr.insert("Sarah", 1);
               Lstr.insert("Jerry", 1);
               Lstr.insert("Tom", 2);
               } catch (Exception e) {prt("Exception " + e + "\n");}
           prt("\nList: " + Lstr.toString() + "\n");
       }
   }// end class listarr

In: Computer Science