Text Book Solutions :
Java How to program 10th Edition Solution manual PDF(Early Objects)
Writer : - Paul Deitel & Harvery Deitel
Get perfect solutions, guidance and help of Java Text Book - How to program early objects 12th, 11th, 10th Edition with 100% accuracy and achieve highest grade in your Assignments as well as in your Examinations.
Salient Features : -
-> Uniqueness and Plagiarism FREE -> We are 24/7 Available
-> Direct Interaction with Our Experts -> Manually coded unique Solutions
-> Achieve 95+ Score -> $9 Per Program Min.
Hi Dear All.
The java Text book - How to program early Objects 10th edition is normally preferred in some college and universities as like in Mission College SANTA CLARA, California etc.Mission college is conducting a Professional course CIS-043-52219 Software Development With Java.If you are the student of this course and getting difficulties in programming then you are on the right place.We committed you to give unique and plagiarism free assignment solutions for each client or student which normally completely different with each other because we have different expert minds and each mind solves same problem in different ways.
Note : - Solutions Manual will be delivered as per requirements only. We manually develop programs to make these plagiarism free.Hence our clients get highest Score rather then other service providers.
Students can select the version of questions for learning also from the text book as per your requirements and interact directly on Skype, whatsapp,chat, sign in with site or by calling us directly any time.We will happy to help you.
Call : +91-995-3141-035
Donate for serving you Better if You Can?
Download Book Java How to Program 10th Edition Click Here
Text Book Questions :
Advanced Object Oriented Programming-2 (PROG36859) Assignment
This assignment must be completed without any outside collaboration in a group of 2 (two) students (Students can form their own groups.) Copying or reproducing the work done by others (in part or in full) or letting others to copy or reproduce your own, and/or unauthorized collaboration will be treated as academic dishonesty under the College’s Academic Dishonesty Policy.
This is an out of class assignment and you are required to complete this assignment at your own time.
Your application must compile and run upon download to receive any mark. Your supplied outputs (e.g., screenshots) may not be marked, if the corresponding program fails to compile and run.
Late submissions will be subject to a reduction in the grade earned as follows: A penalty of 10% of the value of the assignment will be immediately deducted for late submissions. An additional 10% of the value of the assignment will be deducted for each subsequent day (includes weekends and holidays) to a maximum of 3 days at which point the assignment will be assigned a mark of “zero”.
To submit the assignments, please follow the Submission Guideline provided at the end of this assignment.
Each group (both members) MUST demonstrate their work and simulation during the class/lab session on Sep 27th, 2019. Both members must be able to demonstrate the complete work. Demonstration is important and missing it may cost significant part (at least 40%) of this assignment marks.
You must include following information as comments at the beginning of your main class file. o Assignment No.: 1 o Member 1: , o Member 2: , o Submission date: o Instructor’s name: Syed Tanbeer
Total mark = 20 (weight = 10% of the final grade).
Play Card Game
Create a Java program that will simulate a card game in which four players will play the game with a deck of cards. Assume the deck of cards represents a typical playing deck of cards containing 52 cards that has a face rank (e.g., “Ace”, “Deuce”, “Three”…………”Ten”, “Jack”, “Queen”, “King”) and a suit (e.g., “Spades”, “Hearts”, “Diamonds”, “Clubs”). Each suit has 13 cards one for each face. Table 1 and Table 2 show a mapping for the suits and card faces, respectively. You should use these integer code values, NOT the string names, in your simulation program to represent a suit and a card face rank. For example, the code for the card ‘Five of Spade’ should be two integer values as 3 5, where the first value indicates the suite rank (i.e., Spade) and the second value indicates the face rank. Similarly, ‘Ace of Clubs’ = 0 14, ‘Jack of Hearts = 2 11, and so on.
Rules to play:
Step 1 (Shuffle): Shuffle all cards (52 cards in the deck of cards) to obtain a random order for the cards in the deck.
Step 2 (Distribute): Distribute the cards among four players in 13 rounds, starting from the first card in the shuffled deck of cards, i.e., one player will get 1 card from the randomly shuffled deck of card in each round. For example, in the 1st round of distribution, Player-1 will receive the 1st card, Player-2 will receive the 2nd card, Player-3 will receive the 3rd card, and Player-4 will receive the 4th card. In the 2nd round of distribution, Player-1 will receive the 5th card, Player-2 will receive the 6th card, Player-3 will receive the 7th card, and Player-4 will receive the 8th card, and so on. Thus, at the end of the distribution, each player will receive 13 random cards.
Step 3 (Play): There will be 13 rounds of deal in the play. For each round, each player will deal (i.e., play) one card. Each player will play a card in the opposite order he/she received the cards. For example, for the 1st round of deal, all players will play the cards that they received in the 13 th round of distribution. Similarly, in the 2nd round of deal, they will play the cards they received in the 12 th round of distribution, and so on.
Step 4 (Find deal winner): The winner of a deal will be selected based on the face ranks of the cards played by four players. The player who plays the card with the highest face among all four cards in a deal is the winner of that deal. For example, assume the status of the 1st round deal (Deal number 01) of a typical play is as follows (where the first digit indicates face value and the second digit is for suit number). Deal number 01: 3 0, 12 2, 10 0, 4 1 It displays the cards played by all players in sequence of players’ order (i.e., Player-1 has played card 3 0, which is 3 of Clubs, Player-2 has played card 12 2, Player-3 has played 10 0, and Player-4 has played the card 4 1. The winner of this deal is Player-2 (who played the card with the highest face value, i.e., 12). If there is a tie on face values (among more than one cards), the winner will be selected based on the suit rank of cards (the higher suit value will get higher rank). For example, if the status of a round of deal is as follows: Deal number 01: 3 3, 11 2, 7 0, 11 1 Then, the winner of this deal is Player-2 (Player-2 and Player-4 played the highest ranked cards (i.e., 11) in the deal, but Player-2 played a higher suit (i.e., 2) card).
Step 5 (Select the Winner): The overall winner of the game is/are the player(s) who win(s) the highest number of deals among all 13 deals. If there is a tie, add up the face values of all winning deals for each tied player. The player with higher total face value will be the winner. If still there is a tie, all tied players are considered as the winner.
Chapter - 2 Programming Assignment CIS-043-52219 Solutions Manual
2.14 Write an application that displays the numbers 1 to 4 on the same line, with each pair of
adjacent numbers separated by one space. Use the following techniques:
a) Use one System.out.println statement.
b) Use four System.out.print statements.
c) Use one System.out.printf statement.
2.15 (Arithmetic) Write an application that asks the user to enter two integers, obtains them
from the user and prints their sum, product, difference and quotient (division). Use the techniques
shown in Fig. 2.7.
2.16 (Comparing Integers) Write an application that asks the user to enter two integers, obtains
them from the user and displays the larger number followed by the words "is larger". If the numbers
are equal, print the message "These numbers are equal". Use the techniques shown in Fig. 2.15.
2.17 (Arithmetic, Smallest and Largest) Write an application that inputs three integers from the
user and displays the sum, average, product, smallest and largest of the numbers. Use the techniques
shown in Fig. 2.15. [Note: The calculation of the average in this exercise should result in an integer
representation of the average. So, if the sum of the values is 7, the average should be 2, not
2.18 (Displaying Shapes with Asterisks) Write an application that displays a box, an oval, an arrow
and a diamond using asterisks (*), as follows:
2.19 What does the following code print?
2.20 What does the following code print?
2.21 What does the following code print?
2.22 What does the following code print?
2.23 What does the following code print?
System.out.printf("%s%n%s%n%s%n", "*", "***", "*****");
2.24 (Largest and Smallest Integers) Write an application that reads five integers and determines
and prints the largest and smallest integers in the group. Use only the programming techniques you
learned in this chapter.
********* *** * *
* * * * *** * *
* * * * ***** * *
* * * * * * *
* * * * * * *
* * * * * * *
* * * * * * *
* * * * * * *
********* *** * *
2.25 (Odd or Even) Write an application that reads an integer and determines and prints whether
it’s odd or even. [Hint: Use the remainder operator. An even number is a multiple of 2. Any multiple
of 2 leaves a remainder of 0 when divided by 2.]
2.26 (Multiples) Write an application that reads two integers, determines whether the first is a
multiple of the second and prints the result. [Hint: Use the remainder operator.]
2.27 (Checkerboard Pattern of Asterisks) Write an application that displays a checkerboard pattern,
2.28 (Diameter, Circumference and Area of a Circle) Here’s a peek ahead. In this chapter, you
learned about integers and the type int. Java can also represent floating-point numbers that contain
decimal points, such as 3.14159. Write an application that inputs from the user the radius of a circle
as an integer and prints the circle’s diameter, circumference and area using the floating-point value
3.14159 for ð. Use the techniques shown in Fig. 2.7. [Note: You may also use the predefined constant
Math.PI for the value of ð. This constant is more precise than the value 3.14159. Class Math
is defined in package java.lang. Classes in that package are imported automatically, so you do not
need to import class Math to use it.] Use the following formulas (r is the radius):
diameter = 2r
circumference = 2ðr
area = ðr2
Do not store the results of each calculation in a variable. Rather, specify each calculation as the
value that will be output in a System.out.printf statement. The values produced by the circumference
and area calculations are floating-point numbers. Such values can be output with the format
specifier %f in a System.out.printf statement. You’ll learn more about floating-point
numbers in Chapter 3.
2.29 (Integer Value of a Character) Here’s another peek ahead. In this chapter, you learned about
integers and the type int. Java can also represent uppercase letters, lowercase letters and a considerable
variety of special symbols. Every character has a corresponding integer representation. The set
of characters a computer uses together with the corresponding integer representations for those
characters is called that computer’s character set. You can indicate a character value in a program
simply by enclosing that character in single quotes, as in 'A'.
You can determine a character’s integer equivalent by preceding that character with (int), as in
An operator of this form is called a cast operator. (You’ll learn about cast operators in Chapter 4.)
The following statement outputs a character and its integer equivalent:
System.out.printf("The character %c has the value %d%n", 'A', ((int) 'A'));
When the preceding statement executes, it displays the character A and the value 65 (from the Unicode
® character set) as part of the string. The format specifier %c is a placeholder for a character (in
this case, the character 'A').
Using statements similar to the one shown earlier in this exercise, write an application that displays
the integer equivalents of some uppercase letters, lowercase letters, digits and special symbols.
Display the integer equivalents of the following: A B C a b c 0 1 2 $ * + / and the blank character.
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
2.30 (Separating the Digits in an Integer) Write an application that inputs one number consisting
of five digits from the user, separates the number into its individual digits and prints the digits
separated from one another by three spaces each. For example, if the user types in the number 42339,
the program should print
4 2 3 3 9
Assume that the user enters the correct number of digits. What happens when you enter a
number with more than five digits? What happens when you enter a number with fewer than five
digits? [Hint: It’s possible to do this exercise with the techniques you learned in this chapter. You’ll
need to use both division and remainder operations to “pick off ” each digit.]
2.31 (Table of Squares and Cubes) Using only the programming techniques you learned in this
chapter, write an application that calculates the squares and cubes of the numbers from 0 to 10 and
prints the resulting values in table format, as shown below.
2.32 (Negative, Positive and Zero Values) Write a program that inputs five numbers and determines
and prints the number of negative numbers input, the number of positive numbers input and
the number of zeros input.
Making a Difference
2.33 (Body Mass Index Calculator) We introduced the body mass index (BMI) calculator in
Exercise 1.10. The formulas for calculating BMI are
Create a BMI calculator that reads the user’s weight in pounds and height in inches (or, if you prefer,
the user’s weight in kilograms and height in meters), then calculates and displays the user’s
body mass index. Also, display the following information from the Department of Health and
Human Services/National Institutes of Health so the user can evaluate his/her BMI:
4 2 3 3 9
number square cube
0 0 0
1 1 1
2 4 8
3 9 27
4 16 64
5 25 125
6 36 216
7 49 343
8 64 512
9 81 729
10 100 1000
Underweight: less than 18.5
Normal: between 18.5 and 24.9
Overweight: between 25 and 29.9
Obese: 30 or greater
BMI weightInPounds × 703
heightInInches × heightInInches
BMI weightInKilog rams
heightInMeters × heightInMeters
[Note: In this chapter, you learned to use the int type to represent whole numbers. The BMI calculations
when done with int values will both produce whole-number results. In Chapter 3 you’ll
learn to use the double type to represent numbers with decimal points. When the BMI calculations
are performed with doubles, they’ll both produce numbers with decimal points—these are called
2.34 (World Population Growth Calculator) Use the web to determine the current world population
and the annual world population growth rate. Write an application that inputs these values,
then displays the estimated world population after one, two, three, four and five years.
2.35 (Car-Pool Savings Calculator) Research several car-pooling websites. Create an application
that calculates your daily driving cost, so that you can estimate how much money could be saved by
car pooling, which also has other advantages such as reducing carbon emissions and reducing traffic
congestion. The application should input the following information and display the user’s cost per
day of driving to work:
a) Total miles driven per day.
b) Cost per gallon of gasoline.
c) Average miles per gallon.
d) Parking fees per day.
e) Tolls per day.
Chapter - 3 Programming Assignment CIS-043-52219
3.11 (Modified Account Class) Modify class Account (Fig. 3.8) to provide a method called withdraw
that withdraws money from an Account. Ensure that the withdrawal amount does not exceed
the Account’s balance. If it does, the balance should be left unchanged and the method should print
a message indicating "Withdrawal amount exceeded account balance." Modify class AccountTest
(Fig. 3.9) to test method withdraw.
3.12 (Invoice Class) Create a class called Invoice that a hardware store might use to represent
an invoice for an item sold at the store. An Invoice should include four pieces of information as
instance variables—a part number (type String), a part description (type String), a quantity of the
item being purchased (type int) and a price per item (double). Your class should have a constructor
that initializes the four instance variables. Provide a set and a get method for each instance variable.
In addition, provide a method named getInvoiceAmount that calculates the invoice amount (i.e.,
multiplies the quantity by the price per item), then returns the amount as a double value. If the
quantity is not positive, it should be set to 0. If the price per item is not positive, it should be set to
0.0. Write a test app named InvoiceTest that demonstrates class Invoice’s capabilities.
3.13 (Employee Class) Create a class called Employee that includes three instance variables—a
first name (type String), a last name (type String) and a monthly salary (double). Provide a constructor
that initializes the three instance variables. Provide a set and a get method for each instance
variable. If the monthly salary is not positive, do not set its value. Write a test app named EmployeeTest
that demonstrates class Employee’s capabilities. Create two Employee objects and display each
object’s yearly salary. Then give each Employee a 10% raise and display each Employee’s yearly salary
3.14 (Date Class) Create a class called Date that includes three instance variables—a month (type
int), a day (type int) and a year (type int). Provide a constructor that initializes the three instance
variables and assumes that the values provided are correct. Provide a set and a get method for each
instance variable. Provide a method displayDate that displays the month, day and year separated
by forward slashes (/). Write a test app named DateTest that demonstrates class Date’s capabilities.
3.15 (Removing Duplicated Code in Method main) In the AccountTest class of Fig. 3.9, method
main contains six statements (lines 13–14, 15–16, 28–29, 30–31, 40–41 and 42–43) that each display
an Account object’s name and balance. Study these statements and you’ll notice that they differ
only in the Account object being manipulated—account1 or account2. In this exercise, you’ll define
a new displayAccount method that contains one copy of that output statement. The method’s parameter
will be an Account object and the method will output the object’s name and balance. You’ll
then replace the six duplicated statements in main with calls to displayAccount, passing as an argument
the specific Account object to output.
Modify class AccountTest class of Fig. 3.9 to declare the following displayAccount method
after the closing right brace of main and before the closing right brace of class AccountTest:
public static void displayAccount(Account accountToDisplay)
// place the statement that displays
// accountToDisplay's name and balance here
Replace the comment in the method’s body with a statement that displays accountToDisplay’s
name and balance.
Recall that main is a static method, so it can be called without first creating an object of the
class in which main is declared. We also declared method displayAccount as a static method.
When main needs to call another method in the same class without first creating an object of that
class, the other method also must be declared static.
Once you’ve completed displayAccount’s declaration, modify main to replace the statements
that display each Account’s name and balance with calls to displayAccount—each receiving as its
argument the account1 or account2 object, as appropriate. Then, test the updated AccountTest
class to ensure that it produces the same output as shown in Fig. 3.9.
3.16 (Target-Heart-Rate Calculator) While exercising, you can use a heart-rate monitor to see that
your heart rate stays within a safe range suggested by your trainers and doctors. According to the American
Heart Association (AHA) (www.americanheart.org/presenter.jhtml?identifier=4736), the
formula for calculating your maximum heart rate in beats per minute is 220 minus your age in years.
Your target heart rate is a range that’s 50–85% of your maximum heart rate. [Note: These formulas are
estimates provided by the AHA. Maximum and target heart rates may vary based on the health, fitness
and gender of the individual. Always consult a physician or qualified health-care professional before
beginning or modifying an exercise program.] Create a class called HeartRates. The class attributes
should include the person’s first name, last name and date of birth (consisting of separate attributes for
the month, day and year of birth). Your class should have a constructor that receives this data as parameters.
For each attribute provide set and get methods. The class also should include a method that
calculates and returns the person’s age (in years), a method that calculates and returns the person’s
maximum heart rate and a method that calculates and returns the person’s target heart rate. Write a
Java app that prompts for the person’s information, instantiates an object of class HeartRates and
prints the information from that object—including the person’s first name, last name and date of
birth—then calculates and prints the person’s age in (years), maximum heart rate and target-heart-rate
3.17 (Computerization of Health Records) A health-care issue that has been in the news lately is
the computerization of health records. This possibility is being approached cautiously because of
sensitive privacy and security concerns, among others. [We address such concerns in later exercises.]
Computerizing health records could make it easier for patients to share their health profiles and histories
among their various health-care professionals. This could improve the quality of health care,
help avoid drug conflicts and erroneous drug prescriptions, reduce costs and, in emergencies, could
save lives. In this exercise, you’ll design a “starter” HealthProfile class for a person. The class attributes
should include the person’s first name, last name, gender, date of birth (consisting of separate
attributes for the month, day and year of birth), height (in inches) and weight (in pounds). Your class
should have a constructor that receives this data. For each attribute, provide set and get methods.
The class also should include methods that calculate and return the user’s age in years, maximum
heart rate and target-heart-rate range (see Exercise 3.16), and body mass index .
Exercise 2.33). Write a Java app that prompts for the person’s information, instantiates an object of
class HealthProfile for that person and prints the information from that object—including the person’s
first name, last name, gender, date of birth, height and weight—then calculates and prints the
person’s age in years, BMI, maximum heart rate and target-heart-rate range. It should also display
the BMI values chart from Exercise 2.33.
Chapter - 4 - 5 Programming Assignment CIS-043-52219
4.17 (Gas Mileage) Drivers are concerned with the mileage their automobiles get. One driver has
kept track of several trips by recording the miles driven and gallons used for each tankful. Develop
a Java application that will input the miles driven and gallons used (both as integers) for each trip.
The program should calculate and display the miles per gallon obtained for each trip and print the
combined miles per gallon obtained for all trips up to this point. All averaging calculations should
produce floating-point results. Use class Scanner and sentinel-controlled repetition to obtain the
data from the user.
4.18 (Credit Limit Calculator) Develop a Java application that determines whether any of several
department-store customers has exceeded the credit limit on a charge account. For each customer,
the following facts are available:
a) account number
b) balance at the beginning of the month
c) total of all items charged by the customer this month
d) total of all credits applied to the customer’s account this month
e) allowed credit limit.
The program should input all these facts as integers, calculate the new balance (= beginning balance
+ charges – credits), display the new balance and determine whether the new balance exceeds the
customer’s credit limit. For those customers whose credit limit is exceeded, the program should display
the message "Credit limit exceeded".
4.19 (Sales Commission Calculator) A large company pays its salespeople on a commission basis.
The salespeople receive $200 per week plus 9% of their gross sales for that week. For example, a
salesperson who sells $5,000 worth of merchandise in a week receives $200 plus 9% of $5000, or a
total of $650. You’ve been supplied with a list of the items sold by each salesperson. The values of
these items are as follows:
Develop a Java application that inputs one salesperson’s items sold for last week and calculates and
displays that salesperson’s earnings. There’s no limit to the number of items that can be sold.
4.20 (Salary Calculator) Develop a Java application that determines the gross pay for each of
three employees. The company pays straight time for the first 40 hours worked by each employee
and time and a half for all hours worked in excess of 40. You’re given a list of the employees, their
number of hours worked last week and their hourly rates. Your program should input this information
for each employee, then determine and display the employee’s gross pay. Use class Scanner to
input the data.
4.21 (Find the Largest Number) The process of finding the largest value is used frequently in computer
applications. For example, a program that determines the winner of a sales contest would input
the number of units sold by each salesperson. The salesperson who sells the most units wins the contest.
Write a pseudocode program, then a Java application that inputs a series of 10 integers and determines
and prints the largest integer. Your program should use at least the following three variables:
a) counter: A counter to count to 10 (i.e., to keep track of how many numbers have been
input and to determine when all 10 numbers have been processed).
b) number: The integer most recently input by the user.
c) largest: The largest number found so far.
4.22 (Tabular Output) Write a Java application that uses looping to print the following table of
4.23 (Find the Two Largest Numbers) Using an approach similar to that for Exercise 4.21, find
the two largest values of the 10 values entered. [Note: You may input each number only once.]
4.24 (Validating User Input) Modify the program in Fig. 4.12 to validate its inputs. For any input,
if the value entered is other than 1 or 2, keep looping until the user enters a correct value.
5.11 (Find the Smallest Value) Write an application that finds the smallest of several integers.
Assume that the first value read specifies the number of values to input from the user.
5.12 (Calculating the Product of Odd Integers) Write an application that calculates the product
of the odd integers from 1 to 15.
5.13 (Factorials) Factorials are used frequently in probability problems. The factorial of a positive
integer n (written n! and pronounced “n factorial”) is equal to the product of the positive integers from
1 to n. Write an application that calculates the factorials of 1 through 20. Use type long. Display the
results in tabular format. What difficulty might prevent you from calculating the factorial of 100?
5.13 method program: reversed number write a method that takes an integer value and returns the number
with its digits reversed. for example, given the number 7631, the method should return 1367. incorporate the
method into an application that reads a value from the user and displays the result output example: enter an
integer: 98 the original number is 98, and the reversed number 89. actnty 513.1: method program: reversed
number 0/4 main.java load default template..
1 import java.uti1.scanner; 3 public class nain ( 4public static void main(stringt) args) ( scanner scnr -new
scanner(system,in); / type your code here. ii invoke reversed )method and output the result based on user input
5.14 (Modified Compound-Interest Program) Modify the compound-interest application of
Fig. 5.6 to repeat its steps for interest rates of 5%, 6%, 7%, 8%, 9% and 10%. Use a for loop to
vary the interest rate.
5.15 (Triangle Printing Program) Write an application that displays the following patterns separately,
one below the other. Use for loops to generate the patterns. All asterisks (*) should be printed
by a single statement of the form System.out.print('*'); which causes the asterisks to print side
by side. A statement of the form System.out.println(); can be used to move to the next line. A
statement of the form System.out.print(' '); can be used to display a space for the last two patterns.
There should be no other output statements in the program. [Hint: The last two patterns require
that each line begin with an appropriate number of blank spaces.]
(a) (b) (c) (d)
* ********** ********** *
** ********* ********* **
*** ******** ******** ***
**** ******* ******* ****
***** ****** ****** *****
****** ***** ***** ******
******* **** **** *******
******** *** *** ********
********* ** ** *********
********** * * **********
1 // Exercise 5.10: Printing.java
2 public class Printing
4 public static void main(String args)
6 for (int i = 1; i <= 10; i++)
8 for (int j = 1; j <= 5; j++)
14 } // end class Printing
5.16 (Bar Chart Printing Program) One interesting application of computers is to display
graphs and bar charts. Write an application that reads five numbers between 1 and 30. For each
number that’s read, your program should display the same number of adjacent asterisks. For example,
if your program reads the number 7, it should display *******. Display the bars of asterisks after
you read all five numbers.
5.17 (Calculating Sales) An online retailer sells five products whose retail prices are as follows:
Product 1, $2.98; product 2, $4.50; product 3, $9.98; product 4, $4.49 and product 5, $6.87.
Write an application that reads a series of pairs of numbers as follows:
a) product number
b) quantity sold
Your program should use a switch statement to determine the retail price for each product. It
should calculate and display the total retail value of all products sold. Use a sentinel-controlled
loop to determine when the program should stop looping and display the final results.
5.18 (Modified Compound-Interest Program) Modify the application in Fig. 5.6 to use only integers
to calculate the compound interest. [Hint: Treat all monetary amounts as integral numbers
of pennies. Then break the result into its dollars and cents portions by using the division and remainder
operations, respectively. Insert a period between the dollars and the cents portions.]
5.19 Assume that i = 1, j = 2, k = 3 and m = 2. What does each of the following statements print?
a) System.out.println(i == 1);
b) System.out.println(j == 3);
c) System.out.println((i >= 1) && (j < 4));
d) System.out.println((m <= 99) & (k < m));
e) System.out.println((j >= i) || (k == m));
f) System.out.println((k + m < j) | (3 - j >= k));
g) System.out.println(!(k > m));
5.20 (Calculating the Value of π) Calculate the value of π from the infinite series
Print a table that shows the value of π approximated by computing the first 200,000 terms of this
series. How many terms do you have to use before you first get a value that begins with 3.14159?
5.21 (Pythagorean Triples) A right triangle can have sides whose lengths are all integers. The set
of three integer values for the lengths of the sides of a right triangle is called a Pythagorean triple.
The lengths of the three sides must satisfy the relationship that the sum of the squares of two of the
sides is equal to the square of the hypotenuse. Write an application that displays a table of the
Pythagorean triples for side1, side2 and the hypotenuse, all no larger than 500. Use a triple-nested
for loop that tries all possibilities. This method is an example of “brute-force” computing. You’ll
learn in more advanced computer science courses that for many interesting problems there’s no
known algorithmic approach other than using sheer brute force.
5.22 (Modified Triangle Printing Program) Modify Exercise 5.15 to combine your code from
the four separate triangles of asterisks such that all four patterns print side by side. [Hint: Make clever
use of nested for loops.]
5.23 (De Morgan’s Laws) In this chapter, we discussed the logical operators &&, &, ||, |, ^ and !.
De Morgan’s laws can sometimes make it more convenient for us to express a logical expression.
These laws state that the expression !(condition1 && condition2) is logically equivalent to the expression
(!condition1 || !condition2). Also, the expression !(condition1 || condition2) is logically
equivalent to the expression (!condition1 && !condition2). Use De Morgan’s laws to write equivalent
– -- 4
– -- 4
= + + – ----- +…
198 Chapter 5 Control Statements: Part 2; Logical Operators
expressions for each of the following, then write an application to show that both the original expression
and the new expression in each case produce the same value:
a) !(x < 5) && !(y >= 7)
b) !(a == b) || !(g != 5)
c) !((x <= 8) && (y > 4))
d) !((i > 4) || (j <= 6))
5.24 (Diamond Printing Program) Write an application that prints the following diamond
shape. You may use output statements that print a single asterisk (*), a single space or a single newline
character. Maximize your use of repetition (with nested for statements), and minimize the
number of output statements.
5.25 (Modified Diamond Printing Program) Modify the application you wrote in Exercise 5.24
to read an odd number in the range 1 to 19 to specify the number of rows in the diamond. Your
program should then display a diamond of the appropriate size.
5.26 A criticism of the break statement and the continue statement is that each is unstructured.
Actually, these statements can always be replaced by structured statements, although doing so can
be awkward. Describe in general how you’d remove any break statement from a loop in a program
and replace it with some structured equivalent. [Hint: The break statement exits a loop from the
body of the loop. The other way to exit is by failing the loop-continuation test. Consider using in
the loop-continuation test a second test that indicates “early exit because of a ‘break’ condition.”]
Use the technique you develop here to remove the break statement from the application in
Chapter - 6 Programming Assignment CIS-043-52219
6.20 (Circle Area) Write an application that prompts the user for the radius of a circle and uses
a method called circleArea to calculate the area of the circle.
6.21 (Separating Digits) Write methods that accomplish each of the following tasks:
a) Calculate the integer part of the quotient when integer a is divided by integer b.
b) Calculate the integer remainder when integer a is divided by integer b.
Triangle Side 1 Side 2
1 3.0 4.0
2 5.0 12.0
3 8.0 15.0
Fig. 6.15 | Values for the sides of triangles in Exercise 6.15.
240 Chapter 6 Methods: A Deeper Look
c) Use the methods developed in parts (a) and (b) to write a method displayDigits that
receives an integer between 1 and 99999 and displays it as a sequence of digits, separating
each pair of digits by two spaces. For example, the integer 4562 should appear as
4 5 6 2
Incorporate the methods into an application that inputs an integer and calls display-
Digits by passing the method the integer entered. Display the results.
6.22 (Temperature Conversions) Implement the following integer methods:
a) Method celsius returns the Celsius equivalent of a Fahrenheit temperature, using the
celsius = 5.0 / 9.0 * (fahrenheit - 32);
b) Method fahrenheit returns the Fahrenheit equivalent of a Celsius temperature, using
fahrenheit = 9.0 / 5.0 * celsius + 32;
c) Use the methods from parts (a) and (b) to write an application that enables the user either
to enter a Fahrenheit temperature and display the Celsius equivalent or to enter a
Celsius temperature and display the Fahrenheit equivalent.
Call Us to get unique Solutions
6.23 (Find the Minimum) Write a method minimum3 that returns the smallest of three floatingpoint
numbers. Use the Math.min method to implement minimum3. Incorporate the method into an
application that reads three values from the user, determines the smallest value and displays the result.
6.24 (Perfect Numbers) An integer number is said to be a perfect number if its factors, including
1 (but not the number itself), sum to the number. For example, 6 is a perfect number, because 6 =
1 + 2 + 3. Write a method isPerfect that determines whether parameter number is a perfect number.
Use this method in an application that displays all the perfect numbers between 1 and 1000. Display
the factors of each perfect number to confirm that the number is indeed perfect. Challenge the computing
power of your computer by testing numbers much larger than 1000. Display the results.
6.25 (Prime Numbers) A positive integer is prime if it’s divisible by only 1 and itself. For example,
2, 3, 5 and 7 are prime, but 4, 6, 8 and 9 are not. The number 1, by definition, is not prime.
a) Write a method that determines whether a number is prime.
b) Use this method in an application that determines and displays all the prime numbers
less than 10,000. How many numbers up to 10,000 do you have to test to ensure that
you’ve found all the primes?
c) Initially, you might think that n/2 is the upper limit for which you must test to see
whether a number n is prime, but you need only go as high as the square root of n. Rewrite
the program, and run it both ways.
6.26 (Reversing Digits) Write a method that takes an integer value and returns the number with
its digits reversed. For example, given the number 7631, the method should return 1367. Incorporate
the method into an application that reads a value from the user and displays the result.
6.27 (Greatest Common Divisor) The greatest common divisor (GCD) of two integers is the largest
integer that evenly divides each of the two numbers. Write a method gcd that returns the greatest
common divisor of two integers. [Hint: You might want to use Euclid’s algorithm. You can find
information about it at en.wikipedia.org/wiki/Euclidean_algorithm.] Incorporate the method
into an application that reads two values from the user and displays the result.
Chapter - 7 Programming Assignment CIS-043-52219
7.8 Write Java statements to accomplish each of the following tasks:
a) Display the value of element 6 of array f.
b) Initialize each of the five elements of one-dimensional integer array g to 8.
c) Total the 100 elements of floating-point array c.
d) Copy 11-element array a into the first portion of array b, which contains 34 elements.
e) Determine and display the smallest and largest values contained in 99-element floatingpoint
7.10 (Sales Commissions) Use a one-dimensional array to solve the following problem: A company
pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9% of
their gross sales for that week. For example, a salesperson who grosses $5,000 in sales in a week receives
$200 plus 9% of $5,000, or a total of $650. Write an application (using an array of counters)
that determines how many of the salespeople earned salaries in each of the following ranges (assume
that each salesperson’s salary is truncated to an integer amount):
i) $1,000 and over
Summarize the results in tabular format.
7.12 (Duplicate Elimination) Use a one-dimensional array to solve the following problem:
Write an application that inputs five numbers, each between 10 and 100, inclusive. As each number
is read, display it only if it’s not a duplicate of a number already read. Provide for the “worst case,”
in which all five numbers are different. Use the smallest possible array to solve this problem. Display
the complete set of unique values input after the user enters each new value.
7.14 (Variable-Length Argument List) Write an application that calculates the product of a series
of integers that are passed to method product using a variable-length argument list. Test your method
with several calls, each with a different number of arguments.
7.15 (Command-Line Arguments) Rewrite Fig. 7.2 so that the size of the array is specified by the
first command-line argument. If no command-line argument is supplied, use 10 as the default size
of the array.
7.16 (Using the Enhanced for Statement) Write an application that uses an enhanced for statement
to sum the double values passed by the command-line arguments. [Hint: Use the static
method parseDouble of class Double to convert a String to a double value.]
7.17 (Dice Rolling) Write an application to simulate the rolling of two dice. The application
should use an object of class Random once to roll the first die and again to roll the second die. The
sum of the two values should then be calculated. Each die can show an integer value from 1 to 6, so
the sum of the values will vary from 2 to 12, with 7 being the most frequent sum, and 2 and 12 the
least frequent. Figure 7.28 shows the 36 possible combinations of the two dice. Your application
should roll the dice 36,000,000 times. Use a one-dimensional array to tally the number of times
each possible sum appears. Display the results in tabular format.
7.29 (Fibonacci Series) The Fibonacci series
0, 1, 1, 2, 3, 5, 8, 13, 21, …
begins with the terms 0 and 1 and has the property that each succeeding term is the sum of the two
a) Write a method fibonacci(n) that calculates the nth Fibonacci number. Incorporate
this method into an application that enables the user to enter the value of n.
b) Determine the largest Fibonacci number that can be displayed on your system.
c) Modify the application you wrote in part (a) to use double instead of int to calculate
and return Fibonacci numbers, and use this modified application to repeat part (b).
Chapter - 8 Programming Assignment CIS-043-52219
8.2 (Based on Section 8.14) Explain the notion of package access in Java. Explain the negative
aspects of package access.
8.3 What happens when a return type, even void, is specified for a constructor?
8.4 (Rectangle Class) Create a class Rectangle with attributes length and width, each of which
defaults to 1. Provide methods that calculate the rectangle’s perimeter and area. It has set and get
methods for both length and width. The set methods should verify that length and width are each
floating-point numbers larger than 0.0 and less than 20.0. Write a program to test class Rectangle.
8.5 (Modifying the Internal Data Representation of a Class) It would be perfectly reasonable
for the Time2 class of Fig. 8.5 to represent the time internally as the number of seconds since midnight
rather than the three integer values hour, minute and second. Clients could use the same public
methods and get the same results. Modify the Time2 class of Fig. 8.5 to implement the time as
the number of seconds since midnight and show that no change is visible to the clients of the class.
8.6 (Savings Account Class) Create class SavingsAccount. Use a static variable annualInterestRate
to store the annual interest rate for all account holders. Each object of the class contains a
private instance variable savingsBalance indicating the amount the saver currently has on deposit.
Provide method calculateMonthlyInterest to calculate the monthly interest by multiplying the
savingsBalance by annualInterestRate divided by 12—this interest should be added to savings-
Balance. Provide a static method modifyInterestRate that sets the annualInterestRate to a new
value. Write a program to test class SavingsAccount. Instantiate two savingsAccount objects,
saver1 and saver2, with balances of $2000.00 and $3000.00, respectively. Set annualInterestRate
to 4%, then calculate the monthly interest for each of 12 months and print the new balances for
both savers. Next, set the annualInterestRate to 5%, calculate the next month’s interest and print
the new balances for both savers.
8.7 (Enhancing Class Time2) Modify class Time2 of Fig. 8.5 to include a tick method that increments
the time stored in a Time2 object by one second. Provide method incrementMinute to increment
the minute by one and method incrementHour to increment the hour by one. Write a
program that tests the tick method, the incrementMinute method and the incrementHour method
to ensure that they work correctly. Be sure to test the following cases:
a) incrementing into the next minute,
b) incrementing into the next hour and
c) incrementing into the next day (i.e., 11:59:59 PM to 12:00:00 AM).
8.8 (Enhancing Class Date) Modify class Date of Fig. 8.7 to perform error checking on the initializer
values for instance variables month, day and year (currently it validates only the month and
day). Provide a method nextDay to increment the day by one. Write a program that tests method
nextDay in a loop that prints the date during each iteration to illustrate that the method works correctly.
Test the following cases:
a) incrementing into the next month and
b) incrementing into the next year.
8.9 Rewrite the code in Fig. 8.14 to use a separate import declaration for each static member
of class Math that’s used in the example.
8.10 Write an enum type TrafficLight, whose constants (RED, GREEN, YELLOW) take one parameter—
the duration of the light. Write a program to test the TrafficLight enum so that it displays the
enum constants and their durations.
8.11 (Complex Numbers) Create a class called Complex for performing arithmetic with complex
numbers. Complex numbers have the form
realPart + imaginaryPart * i
Write a program to test your class. Use floating-point variables to represent the private data of the
class. Provide a constructor that enables an object of this class to be initialized when it’s declared.
Provide a no-argument constructor with default values in case no initializers are provided. Provide
public methods that perform the following operations:
a) Add two Complex numbers: The real parts are added together and the imaginary parts
are added together.
b) Subtract two Complex numbers: The real part of the right operand is subtracted from
the real part of the left operand, and the imaginary part of the right operand is subtracted
from the imaginary part of the left operand.
c) Print Complex numbers in the form (realPart, imaginaryPart).
8.12 (Date and Time Class) Create class DateAndTime that combines the modified Time2 class of
Exercise 8.7 and the modified Date class of Exercise 8.8. Modify method incrementHour to call
method nextDay if the time is incremented into the next day. Modify methods toString and toUniversalString
to output the date in addition to the time. Write a program to test the new class DateAndTime.
Specifically, test incrementing the time to the next day.
8.13 (Set of Integers) Create class IntegerSet. Each IntegerSet object can hold integers in the
range 0–100. The set is represented by an array of booleans. Array element a[i] is true if integer i
is in the set. Array element a[j] is false if integer j is not in the set. The no-argument constructor
initializes the array to the “empty set” (i.e., all false values).
Provide the following methods: The static method union creates a set that’s the set-theoretic
union of two existing sets (i.e., an element of the new set’s array is set to true if that element is true
in either or both of the existing sets—otherwise, the new set’s element is set to false). The static
method intersection creates a set which is the set-theoretic intersection of two existing sets (i.e.,
an element of the new set’s array is set to false if that element is false in either or both of the
existing sets—otherwise, the new set’s element is set to true). Method insertElement inserts a new
integer k into a set (by setting a[k] to true). Method deleteElement deletes integer m (by setting
a[m] to false). Method toString returns a String containing a set as a list of numbers separated
by spaces. Include only those elements that are present in the set. Use --- to represent an empty
set. Method isEqualTo determines whether two sets are equal. Write a program to test class IntegerSet.
Instantiate several IntegerSet objects. Test that all your methods work properly.
8.14 (Date Class) Create class Date with the following capabilities:
a) Output the date in multiple formats, such as
June 14, 1992
b) Use overloaded constructors to create Date objects initialized with dates of the formats
in part (a). In the first case the constructor should receive three integer values. In the
second case it should receive a String and two integer values. In the third case it should
receive two integer values, the first of which represents the day number in the year.
[Hint: To convert the String representation of the month to a numeric value, compare
Strings using the equals method. For example, if s1 and s2 are Strings, the method
call s1.equals(s2) returns true if the Strings are identical and otherwise returns
Solution available with code EES
Modeling and Investigation of Refrigeration System
Performance with Two-Phase Fluid Injection in a
Scroll Compressor Mechanical Engineering EES
In this assignment, you will work on a real life research problem. Our network lab hosts the UK Satellite Simulator. We use it to simulate Internet traffic to small Pacific islands that are connected to the rest of the world via a satellite link.
To do this, the simulator has a number of machines (“source hosts”) on the “world side” of the simulated satellite link that transmit data in the form of small chunks of up to 1500 bytes called packets. These packets travel via a simulated satellite link to the “island side”. Once on the island side, each packet ends up at a machine there. These machines are called “destination hosts”.
The simulated satellite link delays packets and occasionally throws some away when there are more packets arriving that it can deal with at the moment. When the link throws packets away, the source hosts respond by sending less data for a while before attempting to send more again.
On the island side of the satellite link, our simulator eavesdrops on the incoming packets. It stores summary information about each packet in a trace file. The trace file is plain text and each line contains the record for exactly one packet (more on the file format in the next section).
What we would like to be able to do is get a tabular display of how much data comes from a particular source host over time, or how much data goes to a particular destination host over the course of an experiment. Experiments typically take between 90 seconds and about 11 minutes.
This is where your assignment comes in: You are to build an application that displays this data in tabular form.
In the next section, we’ll look at the structure of our trace files, before we take you through the steps for building the application.
The total size of a trace file can vary substantially depending on the number of hosts involved in an experiment and the length of the experiment. On Canvas, there are two trace files for you to experiment with: a small one with 148315 lines, and a large one with 651274 lines. You can open them in text editors such as Notepad++. And yes you can edit them, too!
To get a good idea of your “typical” line, scroll down a good bit – the lines/packets at the start and at the end are a bit unusual. The following shows a bunch of typical lines from the large trace file:
The lines here have been truncated to be able to accommodate them on the page, but they show all the data you will need. Each line consists of a number of fields separated by a single tab character. Note that fields may be empty, in which case you get two successive tab characters.
The first field on the left is just a sequential number for each packet that is added by the eavesdropping program. The second field is a time stamp that is also added by the eavesdropping program. Each trace file starts with a time stamp of 0.000000000 for the first packet in the file.
The third field in each line is the IP address of the source host. IP addresses identify machines on the network and help routers forward packets between source and destination. Each IP address consists of four decimal numbers between 0 and 255 separated by dots (full stops).
The trace files here only show packets heading towards destination hosts on the island side, so all source host IP addresses start with “192.168.0.”, indicating that they are “world side” addresses.
The fifth field is the IP address of the destination host from the island network. All of the island addresses start with “10.0.”. You will need the third or the fifth field to populate the combo box depending on the status of the radio buttons.
The fourth and the sixth field are the TCP ports on the hosts that the respective packets travel between. They identify the applications that have sent or would have received the packets, but are not relevant for your assignment.
Fields seven, eight and nine are packet sizes in bytes. The size we’re interested in here is that in field eight, it’s the IP packet size. The size in field seven is that of the whole Ethernet frame that contains the IP packet, and field nine is the TCP payload size (the size of the content of the IP packet).
There are also a number of additional fields: various flags, packet sequence and acknowledgment numbers, which are all irrelevant for your task. You only need to look at four fields: time stamp, source and destination IP addresses, and IP packet size. Note that some packets are not IP packets, meaning that the IP packet size field can be empty.
Step 1: Getting started
A basic structure of this assignment is given, you are expected to complete the class design for this assignment, but there are some fairly obvious parts to the design: Firstly, it’s a GUI application with one window, so you’ll need a JFrame. In all our GUI applications in the lectures, we have extended that JFrame by a dedicated subclass for the application. So you’ll probably want to do the same here.
The Swing components are all associated with the JFrame, so you’ll need to import the associated packages, configure the components and add them to the JFrame either directly or via their respective parent. The ListOWords and Album applications from the lectures/supporting material are good examples for how to do this. Don’t forget to configure the ButtonGroup to link your radio buttons!
One exception is the JPanel that shows the data in tabular form. It would be best to extend JPanel, so a more specialised subclass can take care of the table drawing.
Start by placing all components visibly within the JFrame – you may wish to set the JPanel background colours to something a bit different so you can see where in the JFrame they end up being positioned. Remember that a larger vertical position value puts the component further down in the frame. Suggested values that work for me (but aren’t compulsory):
The JFrame has size 1000 by 500.
I’ve put the JPanel with the radio buttons at position 0,0 (upper left corner of the JFrame’s content pane) and made it 200 wide and 100 tall.
The JPanel subclass with the table is at 0,100 (relative to the JPanel) and is 1000 wide by 1300 tall.
You can earn a total of 20 marks in this step:
JFrame subclass correctly started via a class implementing Runnable & using invokeLater(): 4 marks
Menu bar present, showing a File menu with the two required items: 4 marks.
Menu item “Quit” quits the application and Menu item “Open trace file” opens a JFileChooser: 4 marks
The two radio buttons are visible: 4 marks
The radio buttons are mutually exclusive and one is selected by default: 4 marks
In order to get the marks for positioning, no components or labels must touch each other or overlap with other components (i.e., the JFrame and its contents must look neat and tidy).
Step 2: Extract the source and destination hosts from the trace file
First ensure that the combo box is invisible before you open the first trace file.
Using the trace file selected by the JFileChooser, parse the file to extract the source and destination hosts. Check which radio button is active and show the respective set of hosts selected in the combo box.
Hint: There are a few little catches here:
1) Splitting lines can be done with the split() method of the String class, which takes a regular expression as its parameter.
2) The lists must not contain duplicates, so you can’t simply add each line’s host entry to an ArrayList and then load that ArrayList into the JComboBox. Instead, Java has a data structure quite similar to an ArrayList that doesn’t allow duplicates: the HashSet class. It implements the Set interface, and for Strings, you can use it as follows:
If aStringWeMayOrMayNotHaveSeenBefore is not yet in the hash set myUniqueStrings, it will be added. If the string is already in the set, the add() method does nothing.
3) The lists must only contain IP addresses of IP version 4 (IPv4). Some packets in the trace file are not IP packets and the entries for source and destination in the respective lines will be empty. You must skip these packets. Think regular expressions, perhaps.
4) The lists in the combo box must be sorted. To do this, you need to figure out how to sort IP addresses in Java. This can be done in a number of ways. I use Collections.sort() and store the IP addresses in a class that has an appropriate compareTo() method.
Once you have accomplished this, ensure that the combo box updates every time you click the other radio button and every time you open a new trace file.
For this, you need to:
Implement and add the necessary event handlers for the radio button.
Implement the code required to (where applicable) fetch the list of hosts (should you generate these lists once when you load the file, or each time the radio buttons change?).
Implement the code required to wipe and re-populate the combo box. Look to the Album example from the lectures/supporting material for a guide here.
Ensure that you get the correct list of hosts in the combo box each time.
You can earn a total of 30 marks in this step:
The combo box is invisible before the trace file is selected and opened: 3 marks
The application shows some evidence of a trace file being opened and its contents being processed after one selects a file with the JFileChooser (e.g., table plot appearing, combo box getting populated with sensible data): 7 marks
The combo box becomes visible at this point in time: 4 marks
The combo box contains a list of IP addresses: 4 marks
The list contains the selected type of host addresses (192.168.0.x if source hosts are selected, 10.0.x.x for destination hosts): 4 marks
The list updates correctly when a radio button is chosen: 4 marks
The list updates correctly when we open a new trace file: 4 marks
We use coderunner questions to test the correctness of data retrieved from the trace file. You can earn a total of 10 marks in this step. Complete question 1 to question 5 in coderunner.
Step 3: Compute and show tabular data
Implement the necessary code to:
Create a JTable and associated custom table model and add them to your custom JPanel. Note: you would also need to use a scroll pane (JScrollPane class) to accommodate all table records.
Compute the total number of bytes (packet size) that the selected source/destination host sent/received. [For the first of the two additional table rows]
Compute the average number of bytes across all data rows. [For the second additional row]
In order to fulfil the requirements of editable cells and other cell rendering requirements, you would need to create your own custom table model (model in MVC), which can be performed by creating a subclass of AbstractTableModel class of the Java API. You should then be able to link this custom table model to your JTable (view in MVC) by setting your custom model object as the table model for your JTable object.
Use table cell rendering to improve the aesthetics of the table view.
Ensure that the changes made to the editable fields are visible in the trace files, whenever user presses the ‘enter’ key (or ‘return’ key) after editing a cell value.
You can earn a total of 45 marks in this step:
The application shows a table of sorts: 3 marks
The data table is actually correct (as per the text file) and corresponds to the host selected: 3 marks
The table updates correctly when a radio button is chosen: 2 marks
The IP address column name updates correctly when a radio button is chosen: 2 marks
The table updates correctly when an IP address is chosen: 2 marks
The table updates correctly when we open a new trace file: 3 marks
The table shows all relevant column and row values (i.e. table rows and columns are scrollable): 3 marks
There are two additional rows at the end of the table representing the Average and Total IP Packet Size for each table view: 6 marks
The two additional rows should be rendered in a different color than the rest of the table: 3 marks
Innovative look and feel of the table structure and table data: 3 marks
The table cell values of the last column (IP packet size) are editable: 3 marks
The changes made to the editable fields are visible in an external text file (i.e. user saves all valid packets into a text file): 12 marks
We use coderunner questions to test the correctness of the data in the table. You can earn a total of 10 marks in this step. Complete question 6 to question 7 in coderunner.
Step 4: Document your classes
Document your design. The documentation must consist of:
1) “Javadoc” style comments for each public non-inherited method in your code (except for event handlers in anonymous classes). See “Writing Doc Comments” under:
Your comments only need a description of what the method does and the @zaman and @return block tags.
You can earn a total of 5 marks in this step:
Javadoc comments: 5 marks (minus one mark for each un-/incorrectly documented method)
I strongly recommend that you use Eclipse for this project. One particular challenge is the parsing of the trace file. Much of the intermediate operations here happen behind the scenes – there is no visible output till the very end of a lot of these operations and many things that can potentially go wrong. One nice feature in Eclipse is that you can still use System.out.println() etc. to write to the console, so you can add such statements to check that your code behaves as expected. You’ll also get to see any stack traces when exceptions are thrown. And of course, you can add breakpoints and debug using Eclipse’s debugging features!