These are my instructions:
Your data should have been read in from the data file and stored into an array. Next you need to calculate the following and display in a single Message box:
Your program should be written using methods and should be well documented internally and externally. Your output should be displayed using Message boxes.
This is the .text file to use with the instructions:
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 20 21 22 23 24 25 20 21 22 23 24 25 26 27 28 29 30 26 27 28 29 30 26 27 28 29 30 31 32 33 34 35 31 32 33 34 35 31 32 33 34 35 31 32 33 34 35 31 32 33 34 35 40 41 42 43 44 45 40 41 42 43 44 45 40 41 42 43 44 45 40 41 42 43 44 45 40 41 42 43 44 45 45 46 47 48 49 50 45 46 47 48 49 50 45 46 47 48 49 50 45 46 47 48 49 50 45 46 47 48 49 50 45 46 47 48 49 50 45 46 47 48 49 50 48 49 50 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 20 21 22 23 24 25 20 21 22 23 24 25 26 27 28 29 30 26 27 28 29 30 26 27 28 29 30 31 32 33 34 35 31 32 33 34 35 31 32 33 34 35 31 32 33 34 35 31 32 33 34 35 40 41 42 43 44 45 40 41 42 43 44 45 40 41 42 43 44 45 40 41 42 43 44 45 40 41 42 43 44 45 45 46 47 48 49 50 45 46 47 48 49 50 45 46 47 48 49 50 45 46 47 48 49 50 45 46 47 48 49 50 45 46 47 48 49 50 45 46 47 48 49 50 48 49 50 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 20 21 22 23 24 25 20 21 22 23 24 25 26 27 28 29 30 26 27 28 29 30 26 27 28 29 30 31 32 33 34 35 31 32 33 34 35 31 32 33 34 35 31 32 33 34 35 31 32 33 34 35 40 41 42 43 44 45 40 41 42 43 44 45 40 41 42 43 44 45 40 41 42 43 44 45 40 41 42 43 44 45 45 46 47 48 49 50 45 46 47 48 49 50 45 46 47 48 49 50 45 46 47 48 49 50 45 46 47 48 49 50 45 46 47 48 49 50 45 46 47 48 49 50 48 49 50 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 35 36 37 38 39 40 41 42 43 44 45 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 38 39 40 41 42 20 21 22 23 24 25 20 21 22 23 24 25 26 27 28 29 30 26 27 28 29 30 26 27 28 29 30 31 32 33 34 35 31 32 33 34 35 31 32 33 34 35 31 32 33 34 35 31 32 33 34 35 40 41 42 43 44 45 40 41 42 43 44 45 40 41 42 43 44 45 40 41 42 43 44 45 40 41 42 43 44 45 45 46 47 48 49 50 45 46 47 48 49 50 45 46 47 48 49 50 45 46 47 48 49 50 45 46 47 48 49 50 45 46 47 48 49 50 45 46 47 48 49 50 48 49 50
This is my code that I have so far:
public static double getAverage(int[] scores)
{
double sum = 0;
for(int i=0; i<scores.length; i++)
sum += scores[i];
return sum/scores.length;
}
public static int highestScore(int []scores)
{
int highest = scores[0];
for(int i=1; i<scores.length; i++)
if(highest < scores[i])
highest = scores[i];
return highest;
}
public static int lowestScore(int []scores)
{
int lowest = scores[0];
for(int i=1; i<scores.length; i++)
if(lowest > scores[i])
lowest = scores[i];
return lowest;
}
public static int getMode(int[] count)
{
int mode = 1;
for(int i=1; i<count.length; i++)
{
if(count[i] > mode)
mode = count[i];
}
return mode;
}
public static void main(String args[])
{
String filename = "scores.txt";
File file = new File(filename);
int perfectScoresCounter = 0; // counts the number of perfect
scores in the file
int count=0;
//Counts the number of elements in the file.
try
{
Scanner inputFile = new Scanner(file);
// reads elements from the file
while(inputFile.hasNextInt())
{
count++;
inputFile.nextInt();
}
inputFile.close();
}
catch(Exception e)
{
System.out.println("Error in opening file.....");
}
// Initializes array.
int[] scores = new int[count];
try
{
int arrIndex = 0; // initializes array index
Scanner inputFile = new Scanner(file);
while(inputFile.hasNextInt())
{
scores[arrIndex] = inputFile.nextInt();
arrIndex++;
}
inputFile.close();
}
catch(Exception e)
{
System.out.println("Error in opening file.....");
}
// Displays the result.
JOptionPane.showMessageDialog(null, "Average score is " +
getAverage(scores));
JOptionPane.showMessageDialog(null,"Max Score is " +
lowestScore(scores));
JOptionPane.showMessageDialog(null,"Min Score is " +
highestScore(scores));
JOptionPane.showMessageDialog(null,"Mode Score is " +
getMode(count));
System.exit(0);
}
}
My Question is:
I am getting this message "java:113: error: incompatible types:
int cannot be converted to int[]
JOptionPane.showMessageDialog(null,"Mode Score is " +
getMode(count));" when I run my code. What am I doing wrong with my
code concerning getting the mode?
You should be passing the scores instead of count in the getMode() method
I ran the program and its working fine.
JOptionPane.showMessageDialog(null,"Mode Score is " + getMode(scores));
=========================================================================================
These are my instructions: Your data should have been read in from the data file and stored into ...
Do the Academy Awards involve discrimination based on age? Listed below are the ages of actresses and actors at the times that they won Oscars in the Best Actress and Best Actor categories. the ages are listed in order, beginning with the first Academy Awards ceremony in 1928. (Note: in 1968 there was a tie in the Best Actress category, and the mean of the two ages is used; in 1932 there was a tie in the Best Actor category,...
Inferences from Two Samples chapter Listed below are the ages of actresses the awards ceremony, but the ages in and actors at the times that they won the table below are based on the birth Oscars for the categories of Best Actress date of the winner and the date of the and Best Actor. The ages aze listed in awards certmony) chronological otder by row, so that cor- responding locations in the two tables Analyzing the Results are from the...
Sample Data Sample Data Hour Sample Taken Hour Sample Taken 1 4 5 X 1 3 1 42 2 3 4 5 6 2 39 36 25 60 28 53 22 56 41 34 43 45 59 42 36 40 45 39 48 26 42 34 61 48 45 29 3 31 61 38 40 54 26 38 42 37 41 53 37 47 41 37 29 20 26 43 38 33 37 37 35 33 36 41 25 37...
In the graph above which of the following has the largest molecular size? 1 2 3 4 not enough information to determine 0.35 0.3 o 0.25 o 0.2 20.15 0.1 0.05 CN 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 5354 Fraction
Please answer this like right now West Battery Corp. has recently been receiving complaints from retailers that its 9-volt batteries are not lasting as long as other name brands. James West, head of the TQM program at West's Austin plant, believes there is no problem because his batteries have had an average life of 40 hours, about 10% longer than competitors' models. To raise the lifetime above this level would require a new level of technology not available to West....
You are studying an invasive insect species in the USA. Understanding where invasive species comes from can help with management (e.g., importation of native natural enemies for biocontrol). The graph below shows output from a STRUCTURE analysis of 10 microsatellite markers in 50 individuals taken from the invasive US population, and the three native countries of origin, Spain, France, and Italy. A-1pt) How many genetic groups, or clusters, were identified in the analysis? Assuming you’ve completely sampled the native range...
I literally have no idea what I’m doing. Help!!! Please show work!! Write an essay using Word and post it as an attachment to the discussion. Cover the following points. Choose a data set from Stat Disk using one of the following files from 13th Edition Elementary Statistics: Oscar Winner Freshman 15 Word Count Garbage Weights Passive and Active Smoke If the file contains more than one variable, choose a quantitative variable. Create a histogram using your chosen variable and...
For a population, the value of the standard deviation is 2.77. A random sample of 35 observations taken from this population produced the following data. 42 52 42 31 28 36 50 29 46 37 32 27 33 41 47 40 28 46 34 39 48 25 35 37 38 46 48 39 29 31 44 41 37 38 46 Round your answers to 2 decimal places. a. What is the point estimate of μ? _____ b. Make a 98%...
NUMBER OF PEOPLE 10.2 10.0 10.1 8.5 10.2 8.2 8 Source: United States Census. 11. In the Sanitary District of Chicago, operating engineers are hired on of a competitive civil-service examination. In 1966, there were 223 appl for 15 jobs. The exam was held on March 12; the test scores are s arranged in increasing order. The height of each bar in the histogram next page) shows the number of people with the correspondin examiners were charged with rigging the...
mips add matrix Can anyone help me with adding matrix in MIPS? This is the code given. We will be using it to run it in spim-cache Write an assembly code program to perform addition between two matrices A and B, and store the result into a matrix C, i.e, 1 2 3 4 51 [26 27 28 29 301 27 29 31 33 35 6 7 8 9 10 31 32 33 34 35 37 39 41 43 45...