Question
Please I need help with my homework. Someone who has Eclipse and must use Java programming language.The code is not working and giving me errors.
Please I need help with my homework. Someone who has Eclipse and must use Java programming language.The code is not working and giving me errors. I want it to go to my input.txt and my output.txt but it is not working. Also I need help for the deposit section, a code for when the account number is valid but the deposit amount is invalid. Please keep my PrintWriter, Scanner and File the same. You can change the rest of the code if you will like.
This is what I will like my PrintWriter, Scanner and File to stay as.
//open the input file
File myfile = new File("input.txt"); //file object
//create a Scanner object to read the input file
Scanner inputFile= new Scanner(myfile);
//create an output file object using the PrintWriter class
PrintWriter outputFile = new PrintWriter("output.txt");
This is the program:
This is the homework assignment:
eimport java.io.*; 3 import java.util.Scanner 5 public class HW6 f 7 public static void main(String[] args) throws I0Exception t 4 9 10 //open the input file File myfilenew File("input.txt"); //file object 12 13 14 15 16 17 18 19 20 21 //create a Scanner object to read the input file Scanner inputFile- new Scanner(myfile); //create an output file object using the Printwriter class Printwriter outputFilenew Printwriter("output.txt"); int MAX_ACC-100; int accNum[]-new int [MAX_ACC];//account numbers array double balance []-new double [MAX_ACC];//balance array //read the accounts info from file 23 24 25 26 27 28 29 30 31 int numAccts-readAccts (accNum, balance, MAX_ACC) printAccts(accNum, balance, numAccts);//print initial ascts. to output file char ch'; //do while loop 34 35 36 37 38 39 40 switch(ch) case 'W'://withdraw //create an output file object using the Printwriter class Printwriter outputFilenew Printwriter("output.txt"); 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211e 212 213 214 System.out.println("Enter the account number."); int number- inputFile.nextInt); int index-findAcct (acctNum, numAccts, number); if ( index=-1) outputFile.println("No such account exists."); else outputFile.println("Account Balance: "+balance [index]); inputFile.close); outputFile.closeO; outputFile.flush); public static void removeIndex (int] acctNum, double[] balance, int numAccts, int index) throws I0Exception //open the input file 215 216 217 218 File myfile new File("input2.txt"); I/file object //create a Scanner object to read the input file Scanner inputFile- new Scanner(myfile); 219 220 221 //create an output file object using the PrintWriter class Printwriter outputFilenew Printwriter("output.txt"); 223 224 225 for(int i-index; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started