Assignments are to be turned in on paper. On every assignment, write your name,
course and section number at the top. Write your name as it appears in your university
records! Use the section number for which you are registered! We will not do detective
work to figure out who did what. Work must be legible. Homework is due on paper in
discussion section, usually at the start except when the assignment indicates that time
to work on the assignment will be provided in class. Exceptions will be made only by
advance arrangement with your TA (excepting "acts of God" outside your control).
Never push homework under someone's door!
1. Background: The code for class ScanSupport given at the end of the notes for
Lecture 10 on Sept. 26 raises some questions: Consider writing a nextFloat method
to add to ScanSupport. A preliminary version of this would be very similar to nextName
except that the final two lines would be:
sc.skip( number );
return Float.parseFloat( sc.match().group() );
a) ScanSupport has no tools equivalent to the hasNext methods of the scanner. If there
is no next name on the current input line, what does nextName() return? (This has an
impact on the pattern you use and it is the origin of an error in the above code.)
(0.5 points)
b) Give a declaration for the pattern named number above that recognizes 10, 9.12, 87.
and .6345 (for example), as well as handling the possibility that there is no floating
point number before the end of line. (0.5 points)
c) Fix the code given above so that it returns Float.NaN if there is no next floating
point number on the current input line. (That's a special float value that represents
something that is not a number. If you have a float named f, f.isNaN() tests to see if
the value is not a number.) (0.5 points)
2. Background: Look at the code distributed with Lecture 10 last week. Several
changes were made from the code presented previously. One change is that
several error messages that had been created by concatenating numerous
components have been simplified by using this.toString() in place of most of the
concatenations.
A question: Why not use this.toString to replace the concatenations in other error
messages. For example, why not replace the no-such-intersection error messages
in Road? (0.5 points)
3. Background: In the code distributed with Lecture 10, this code appears:
if (sc.hasNextFloat()) {
travelTime = sc.nextFloat();
if (travelTime < 0.0F) {
Errors.warn( "Negative travel time:" + this.toString() );
travelTime = 99999.0F;
}
} else {
Errors.warn( "Floating point travel time expected: Road "
+ sourceName + " " + dstName
);
travelTime = 99999.0F; // no failure needed, use bogus value
}
Assume you have written ScanSupport.nextFloat(sc,message) where the message
parameter is the context part of the error message to output if there is no next
float, and where it returns Float.NaN if there is no next float.
A question: Rewrite the above code to use this version of ScanSupport.nextFloat. (1
point)
http://www.daixie0.com/contents/9/1247.html
The core members of the team mainly include Silicon Valley engineers, BAT front-line engineers, top 5 master and doctoral students in China, and are proficient in German and English! Our main business scope is to do programming assignments, course design and so on.
Our field of direction: window programming, numerical algorithm, AI, artificial intelligence, financial statistics, econometric analysis, big data, network programming, WEB programming, communication programming, game programming, multimedia linux, plug-in programming program, API, image processing, embedded/MCU database programming, console process and thread, network security, assembly language hardware Programming software design engineering standards and regulations. The ghostwriting and ghostwriting programming languages or tools include but are not limited to the following:
C/C++/C# ghostwriting
Java ghostwriting
IT ghostwriting
Python ghostwriting
Tutored programming assignments
Matlab ghostwriting
Haskell ghostwriting
Processing ghostwriting
Building a Linux environment
Rust ghostwriting
Data Structure Assginment
MIPS ghostwriting
Machine Learning homework ghostwriting
Oracle/SQL/PostgreSQL/Pig database ghostwriting/doing/coaching
web development, website development, website work
ASP.NET website development
Finance Insurance Statistics Statistics, Regression, Iteration
Prolog ghostwriting
Computer Computational method
Because professional, so trustworthy. If necessary, please add QQ: 99515681 or email: [email protected]
WeChat: codinghelp