Java program
The file enrollments.txt is a text file with each line containing a positive integer that represents the enrollment in a section of CIS 103. The highest value is 36. Write a program to read the data from the file into an array, then calculate and display the number of sections, the average class size, the minimum class size, and the maximum class size.
enrollments.txt
36
36
36
34
35
25
34
31
29
19
35
33
36
32
34
25
36
36
36
32
34
31
30
please do in netbeans.
Code
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
public class classEnrollment
{
public static void main(String args[]) throws
FileNotFoundException, IOException
{
BufferedReader br = new
BufferedReader(new FileReader("enrollments.txt"));
//if number of Sections has to be
Increased just go to higher value in new int[ ]
int arr[] = new int[24];
int index = 0;
int sum = 0;
String line =
br.readLine();
while(line != null)
{
int j =
Integer.parseInt(line);
sum += j;
arr[index] =
j;
index++;
line =
br.readLine();
}
int minimumvalue = arr[0],
maximumvalue = arr[0];
// Finding Minimum value and
Maximum value of the class
for(int i = 0; i < arr.length;
i++)
{
//To find
Minimum Class Size
if(minimumvalue
> arr[i])
{
minimumvalue = arr[i];
}
//To find
Maximum Class Size
if(maximumvalue
< arr[i])
{
maximumvalue = arr[i];
}
}
// Finding the average of
Section 103
float avg = sum/arr.length;
System.out.println("\nSections of
CSE 103 : " +Arrays.toString(arr));
System.out.println("\nTotal number
of Sections : "+arr.length);
System.out.println("Average Class
Size : "+avg);
System.out.println("Section which contains minimum
Class Size or Students : "+minimumvalue);
System.out.println("Section which contains maximum
Class Size or Students : "+maximumvalu
Java program The file enrollments.txt is a text file with each line containing a positive integer...
Use two files for this lab: your C program file, and a separate text file containing the integer data values to process. Use a while loop to read one data value each time until all values in the file have been read, and you should design your program so that your while loop can handle a file of any size. You may assume that there are no more than 50 data values in the file. Save each value read from...
Write a complete Java program in a file caled Module1Progrom.java that reads all the tokens from a file named dota.txt that is to be found in the same directory as the running program. The program should ignore al tokens that cannot be read as an integer and read only the ones that can. After reading all of the integers, the program should print all the integers back to the screen, one per line, from the smalest to the largest. For...
Write a program that reads a file containing an arbitrary number of text integers that are in the range 0 to 99 and counts how many fall into each of eleven ranges. The ranges are 0-9, 10-19, 20-29,..., 90-99 and an eleventh range for "out of range." Each range will correspond to a cell of an array of ints. Find the correct cell for each input integer using integer division. After reading in the file and counting the integers, write...
DESCRIPTION Complete the program using Java to read in values from a text file. The values will be the scores on several assignments by the students in a class. Each row of values represents a specific student's scores. Each column represents the scores of all students on a specific assignment. So a specific value is a specific student's score on a specific assignment. The first two values in the text file will give the number of students (number of rows)...
Java Programming Reading from a Text File Write a Java program that will use an object of the Scanner class to read employee payroll data from a text file The Text file payroll.dat has the following: 100 Washington Marx Jung Darwin George 40 200 300 400 Kar Car Charles 50 22.532 15 30 The order of the data and its types stored in the file are as follows: Data EmployeelD Last name FirstName HoursWorked double HourlyRate Data Tvpe String String...
Write a java program to read from a file “input4_02.txt” an integer N (0? N ? 100) and then read N double numbers from this file to an array. Write to file “output4_02.txt” this array but in the reverse order and also the sum of all elements in the array. For example File: “input4_02.txt” 5 1.30 2.22 4.00 17.60 3.14 File “output4_02.txt” 3.14 17.60 4.00 2.22 1.30 Sum = 28.26
Lab 10 Write a Java program that reads the integer numbers in a text file (numbers.txt) and stores the numbers to a binary file (binaryNumber.dat).The number.txt file contains the following numbers: 1 2 3 4 5 6 7 8 9 0
Java Program Create a class to store an array of with enough space to store 10 integer values. Using the principle of recursion, implement the following: *getSize : returns the size of the array. *get (i): returns the i-th element of the array. If the element does not exist, it throws a "NoSuchElementException” which is a subclass of Java class RunTimeException. *add (val): inserts value as the last element of the array. If necessary, double the size of the current...
This isa Java program Create file, file 1, with the following values: 3 4 35 20 -43 17 -10 6 7 -2 13 1 2 3 Write a program in Java to do the following: Open "file 1" and read the first two values, rand c, which are supposed to indicate the dimensions of the two-dimensional array whose values are given in the file after the values of r and c. Create a two-dimensional array of size r times c....
4.3Learning Objective: To read and write text files. Instructions: This is complete program with one Java source code file named H01_43.java (your main class is named H01_43). Problem: Write a program that prompts the user for the name of a Java source code file (you may assume the file contains Java source code and has a .java filename extension; we will not test your program on non-Java source code files). The program shall read the source code file and output...