
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
i really need help with this java code, when i try to run it, an erros comes up

Transcribed Image Text:PP 8.3 Write a program that creates a histogram that allows
you to visually inspect the frequency distribution of a set of
values. The program should read in an arbitrary number of
integers from a text input file that are in the range 1 to 100
inclusive; then produce a chart similar to the one below that
indicates how many input values fell in the range 1 to 10, 11 to
20, and so on. Print one asterisk for each value entered.
1
- 10 | *****
11 - 20 | **
21 30
| **
31 - 40
I
41 - 50
| ***
51 - 60
| *****
61 - 70
| **
71 - 80
| *****
81 - 90 | **
91 100 **
-
-
file.txt.txt
1 2 3 4 5 6 14 12 13 16 26 24 54 35 36 45 46 56 58 69 69 79 79 91
![Main.java
Main.java
1 import java.io.File;
2 import java.io.FileNotFoundException;
ων
3 import java.util.Scanner;
5 public class Main {
8 69 S
6 ✓
7
8 v
9
10 v
11
2345678
12 v
13
14
15
L6
17
18 ✓
19
20
21
22
23
24 v
5 6 7 8 9
25
26
27
28 ✓
29
public static void main(String[] args) {
int[] range Counts = new int[10];
try {
Scanner scanner = new Scanner(new
File("/Users/justinmora/Downloads/file.txt"));
30
31
32
33 0 }
34 }
while (scanner.hasNextInt()) {
}
int value = scanner.nextInt();
if (value >= 1 && value <= 100) {
int range = (value - 1) / 10;
rangeCounts[range]++;
}
scanner.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
return;
// Print the histogram
for (int i = 0; i < rangeCounts.length; i++) {
int startRange
i * 10 + 1;
int endRange = (i + 1) ⋆* 10;
}
=
System.out.printf("%2d-%2d: ", startRange, endRange);
for (int j = 0; j < rangeCounts[i]; j++) {
System.out.print("*");
System.out.println();
Console X
Shell x
> sh -c javac -classpath .:target/dependency/* -d . $(fi
-type f -name '*.java')
> java -classpath .:target/dependency/* Main
java.io.FileNotFoundException: /Users/justinmora/Downloads/fi
le.txt (No such file or directory)
at java.base/java.io.FileInputStream.open(Native Method)
at java.base/java.io.FileInputStream.open(FileInputStream
.java:216)
at java.base/java.io.FileInputStream.<init>(FileInputStre
.java:157)
at java.base/java.util.Scanner.<init>(Scanner.java:639)
at Main.main(Main.java:9)
am.](https://content.bartleby.com/qna-images/question/13128d36-7a18-409b-baf9-4e9a58dc2e39/e8b04637-8c2b-4920-8d33-951d4b4625e3/acn9zn_thumbnail.png)
Transcribed Image Text:Main.java
Main.java
1 import java.io.File;
2 import java.io.FileNotFoundException;
ων
3 import java.util.Scanner;
5 public class Main {
8 69 S
6 ✓
7
8 v
9
10 v
11
2345678
12 v
13
14
15
L6
17
18 ✓
19
20
21
22
23
24 v
5 6 7 8 9
25
26
27
28 ✓
29
public static void main(String[] args) {
int[] range Counts = new int[10];
try {
Scanner scanner = new Scanner(new
File("/Users/justinmora/Downloads/file.txt"));
30
31
32
33 0 }
34 }
while (scanner.hasNextInt()) {
}
int value = scanner.nextInt();
if (value >= 1 && value <= 100) {
int range = (value - 1) / 10;
rangeCounts[range]++;
}
scanner.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
return;
// Print the histogram
for (int i = 0; i < rangeCounts.length; i++) {
int startRange
i * 10 + 1;
int endRange = (i + 1) ⋆* 10;
}
=
System.out.printf("%2d-%2d: ", startRange, endRange);
for (int j = 0; j < rangeCounts[i]; j++) {
System.out.print("*");
System.out.println();
Console X
Shell x
> sh -c javac -classpath .:target/dependency/* -d . $(fi
-type f -name '*.java')
> java -classpath .:target/dependency/* Main
java.io.FileNotFoundException: /Users/justinmora/Downloads/fi
le.txt (No such file or directory)
at java.base/java.io.FileInputStream.open(Native Method)
at java.base/java.io.FileInputStream.open(FileInputStream
.java:216)
at java.base/java.io.FileInputStream.<init>(FileInputStre
.java:157)
at java.base/java.util.Scanner.<init>(Scanner.java:639)
at Main.main(Main.java:9)
am.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- I am trying to create a digital clock however, it has come to my attention that I forgot to put in a main method. Is there any chance you could help me develop a main method for my program so it compiles? This is my code: public class DigitalClock { private int currentHour; private int currentMinutes; public int getHour() { return currentHour; } public void setHour(int currentHour) { this.currentHour = currentHour; } public int getMinutes() { return currentMinutes; } public void setMinutes(int currentMinutes) { this.currentMinutes = currentMinutes; } public static final int HOUR_MAX = 23; // Refactored hourly max public static final int HOUR_MIN = 0; // Refactored hourly min public static final int MINUTES_MAX = 59; // Refactored minute max public static final int MINUTES_MIN = 0; // Refactored minute min public static final int TOTAL_NUMBERS_HOURS = 24; public static final int…arrow_forwardWrite a JAVA program that uses a timer to print the current time once a second. Hint: The following code prints the current time Date now = new Date(); System.out.println(now); The Date class is in the Java.util package.arrow_forwardIn Java, which Scanner method reads only one word?arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education