The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 340 Weeks Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
can you tell me why I am getting these error messages with this code here is my code error messages:
Done
Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at balance.Bank.main(Bank.java:51)
/**
*
*/
package balance;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
/**
* @author Denise
*
*/
public class Bank {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException
{
String Help="/Users/Denise/Desktop/Help/Help.txt";
{
try(BufferedWriter bw=new BufferedWriter(new FileWriter(Help))){
String content="Denise Hawkinberry 21n ";
bw.write(content);
System.out.println("Done");
}
Scanner inFile = new Scanner(new File("/Users/Denise/Desktop/Help/Help.txt"));
String firstName;
String lastName;
float age;
String string;
String string1;
while (inFile.hasNext())
{
firstName = inFile.nextLine();
lastName = inFile.next();
age = inFile.nextFloat();
}
String line;
while (inFile.hasNextLine())
{
line = inFile.nextLine();
Scanner parseLine = new Scanner(line);
firstName = parseLine.nextLine();
lastName = parseLine.next();
age = parseLine.nextFloat();
// … new Account(firstName, lastName, age);
File file = new File("/Users/Denise/Desktop/Help/Help.txt");
if (!file.canRead()) {
System.err.println(file.getCanonicalPath() + ": cannot be read");
return;
}
}
}
}
}
----------- ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly