CSE 174 - Fall 2018
PROGRAM #5: 30 points – Due Sunday, September 30, by 11:59 p.m.
Outcomes:
? Write programs that obtain user input
? Write programs that implement decisions using if statements and create test cases
? Write programs that work with Strings
? Format and comment source code that adheres to a given set of formatting guidelines
? Use a zip compression tool to combine multiple files
Scoring:
At a bare minimum, the program you submit must have the assigned source code, and your
source code must compile and run without crashing.
? If you do not submit your source code (.java files), your score will be zero.
? If you submit source code that does not compile, your score will be zero.
? If you submit source code that roughly resembles the requirements and it compiles, but
it crashes under normal operating conditions (nice input from the user), your score will
be reduced by 75%. Deductions will be made for not meeting the usual requirements
(properly formatted source code, class names that do not meet specifications, and so
on).
Full credit No credit or Partial credit
Write solutions to the two
given problems (20 points)
The programs you submitted
solved the specified
problems.
The programs you submitted
do not solve or only partially
solve the specified problems
Lists test cases for both the
HexNumbers and Taxes
problems (6 points)
You thoroughly tested your
HexNumbers and Taxes
classes, listing the test cases
that do and do not work
You did not list test cases, or
missed important test cases
Format output as specified
(4 points)
Your output is formatted as
specified, including proper
spacing, spelling, rounding
values to the specified
number of places, and so on
You did not follow some or
all of the requirements for
output
Getting started
1. Review String objects and methods from chapter 2 and 3 of your text.
2. Look up the Java API documentation for the String class, and familiarize yourself with
other useful String methods.
Requirements
1. You will write two separate Java programs
2. (10 points) In a Java class named HexNumbers, write a program that reads three 4-
digit hexadecimal numbers names from the user, and then "parse" that information to
display it in a different format after sorting them. Your program should run as shown in
the sample run below.
Sample run:
Note that Scanners have a method named nextLine(). Use this method to obtain the
strings in a single line of user input. This takes the entire line entered by the user and
stores it in the variable. For example:
String numbers = keyboard.nextLine();
Write code that breaks apart each of the user-entered pieces into smaller, more useful
pieces. For example, you should extract the three numbers into separate variables. This
is the part where you will do the most problem solving.
Some specifics:
? There will always be at least one space after each hexadecimal number.
? There may be extra spaces separating the hexadecimal numbers (as shown in the
example), but there will never be extra spaces IN an hexadecimal number. In
other words, if a number is 5fc8, there may be several spaces before or after
5fc8, but the user won't enter 5f c 8
? The number may contain numbers and letters which could be a mix of lowercase
and uppercase letters, but when it gets printed, all the letters are printed in
uppercase.
? Do not convert the hexadecimal numbers to decimal numbers to determine the
maximum, median and minimum value. Use String methods to obtain that result.
3. (10 points) In a Java class named Taxes, solve problem P3.22 from the end of chapter 3
in your textbook. Sample run:
Another requirement:
? The program must be able to process the words single and married regardless of
their format e.g. sinGLE, maRRied, Single, Married, marrieD, sInGlE
4. (6 points) Test both classes HexNumbers and Taxes thoroughly. Develop a set of test
cases for each class. For instance, the test cases for the class Taxes:
In the HexNumbers and Taxes classes, at the top of the comments, include a list of
the test cases and the expected outputs (Note: Read Section 3.6 about Test Cases). At
least provide 6 test cases for each class.
You should also indicate the test case(s) that did not work for your classes along with
the wrong output it printed. Note that this part of the assignment is worth 6 points. You
can get full credit for this, even if your HexNumbers and Taxes classes do not always
produce the correct answer.
5. Follow these steps to submit your work:
a. Create an empty folder named program5.
b. Put copies of your two source code files (.java) in the program5 folder. Do not put
any other files in that folder. There should be exactly two .java files.
c. Compress the folder to create a zip file. Be sure it ends with .zip.
d. Submit only the zip file to the Canvas website.
Note: If you submit your work and decide to modify one of your programs, you need to
resubmit a new zip file containing all three source code files (even if you only modified one of
them). Do not rename your source code files. Do not rename the zip file. Canvas may add a
number to the name of your zip file. That is fine. But you should keep all filenames the same.
版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。