Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

So Ive posted this question before and didnt get a clear answer. The person told me to put myinput.txt in the same directory as that

So Ive posted this question before and didnt get a clear answer. The person told me to put myinput.txt in the same directory as that of Stats.java file. How do I put it in the same directory. This is my first week coding so please try to explain it in simple terms so that I can understand. Thank You.
image text in transcribed
ecipse-workxpace-HomeWork2/a/homework2/Stats java Eclipse IDt e Edit Source Refactor Navigate Search Project Run Window Help Stats.java Et 4 public class Stats ( 6Adding TOException to main aethod for outputfile. public static void main(Stringll args) throus T0Exception ( / /Declaring variables int IDNumber, rightAns,wrongAns, answered, onitted, grade, numberOf Students int maxGradetD , maxGrade , maxPerID double rightAnspercent, maxPercent -1.0 String message null, oMessage ull 1e 12 13 14 15 //open input File File nyfile-new File("myinput.txt") 16 17 18 19 20 21 //Creating scanner object. Scanner inputFile new Scanner(myfile); / /Scanner inputFile new Scanner (System.in); /read from console //Creating outputFile using Printwriter class. Printuriter outputfile 23 24 25 26 27 28 29 //Attaching object to a file and opening file. outputFile new Printwriter("myoutput.txt") /iprinting Table Header outputFile.printin( titicititititititittttExan Statisticsin") outputFile.printin("Student ID tRighttwrong\tAnswered tOmittedt itGrade t " 31 "Percent ititittMessagetieleititomitted Message) D Console S terminated. Stats (1) lava AppkationCprogramF les laval re-10aabin ymaw exe Clana 2019,24101 PM) Exception in thread "main-iavadonientrounderception: mynput.txt (The system cannot find the file specified) at java.base/java, io.FileInputStream.opene(Native Method) at java.base/java. io.FileInputStream,open (Unknown Source) at java.base/java.Lo.PileInputStream.(Unknown Source) at Homework2/homework2.Stats.main(Stats java:19) Smart Insert O Type here to search

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions