Cashback Offer (20th - 30th September 2020). Get Flat 10% Cashback credited in your account on a minimum transaction of $80. Post Your Question

Question DetailsNormal
$ 20.00

CIS520 Week 4 Assignment Part 1 And Part 2 Lab 4 Java Programming

Question posted by
Online Tutor Profile
request

Part 1 (40 Points) – Strings

Create a package named cs520.hw4.part1. Using this package create the class StringTest and implement the specified functionality in its main method.

a. Ask the user through a single input dialog for the user’s first name last name and age in the format
FirstNameLastNameAge

b. Trim the user’s input in case spaces were entered at the beginning or at the end.

c. Display the trimmed data to the console. Do the following operations using this trimmed string.

d. Find the index of the first comma in the input using the indexOf method. Using this value extract the first name part of the input using the substring method.

e. Display the position of the first comma the first name and the length of the first name to the console.

f. Find the index of the second comma in the input using the indexOf method. Using this value extract the last name part of the input using the substring method.
g. Display the position of the second comma the last name and the length of the last name to the console.

h. Extract the age using the substring method. Convert the value to an integer. Display the age in 10 years from now.

Now examine the code for all possible exceptions that could occur. Using a single try-catch construct handle all the different exceptions explicitly and print out the exception message.
Also test the following inputs where exceptions will occur and your program handles them gracefully — when Cancel is clicked when only the first name is entered when only the first name and the last name are entered and when all the three values are specified but the age is not an integer

Part 2 (60 Points) – StringTokenizer and File Input

Create a package named cs520.hw4.part2. Using this package create the following classes.

Create a class named Student as follows. The class keeps track of the student’s homework grades.
The instance (or member) private variables – name (String) homework1 homework2 homework3 homework4 homework5 and homework6 (all of type integer).
A single constructor with name as its argument.
The public set methods for the six homework instance variables. The get methods are optional.
A public computeAverage method which takes no arguments and returns a double showing the average homework grade for this student.
Override the toString method to return the string representation of this object in the format “The <studentName>’s average grade is <the computed average>”.
Create a Test class to test the following functionality in its main method.

a.Use the BufferedReader class to read the data.txt file. The contents of the file are shown below. Create the data.txt file in HW4_lastName.

b.Read the contents of the text file one line at a time using a loop. The program should work for any number of input lines. Invoke the processInputData method for each line read.

c. Write a private method processInputData which processes its string input argument as follows.

Tokenize the string argument using the StringTokenizer class using the comma as the delimiter.
Extract the name token. Create a Student object and assign to the variable currentStudent.
Read each homework grade token one token at a time. Use the corresponding set method on the student object to set the instance value.
Display the string representation of the currentStudent object to the console.
Sample Input data.txt file:

Alice447985727757

Bob799470717151

Charlie959941556550

Dave878988557463

Ed825144677349

Available Answer
$ 20.00

[Solved] CIS520 Week 4 Assignment Part 1 And Part 2 Lab 4 Java Programming

  • This solution is not purchased yet.
  • Submitted On 09 May, 2017 10:25:43
Answer posted by
Online Tutor Profile
solution
Solution of the above question...
Buy now to view the complete solution
Other Similar Questions
User Profile
Acade...

CIS520 Week 3 Assignment Part 2 Lab 3

Solution of the above question coming soon, kindly message me if you need solution as soon as possible. Am working on it...
User Profile
Acade...

CIS520 Week 4 Assignment Part 1 And Part 2 Lab 4 Java Programming

Solution of the above question coming soon, kindly message me if you need solution as soon as possible. Am working on it...
User Profile
Acade...

CIS520 Week 5 Assignment Lab 5

Solution of the above question coming soon, kindly message me if you need solution as soon as possible. Am working on it...
User Profile
Acade...

CIS520 Week 6 Assignment Lab 6

Solution of the above question coming soon, kindly message me if you need solution as soon as possible. Am working on it...

The benefits of buying study notes from CourseMerit

homeworkhelptime
Assurance Of Timely Delivery
We value your patience, and to ensure you always receive your homework help within the promised time, our dedicated team of tutors begins their work as soon as the request arrives.
tutoring
Best Price In The Market
All the services that are available on our page cost only a nominal amount of money. In fact, the prices are lower than the industry standards. You can always expect value for money from us.
tutorsupport
Uninterrupted 24/7 Support
Our customer support wing remains online 24x7 to provide you seamless assistance. Also, when you post a query or a request here, you can expect an immediate response from our side.
closebutton

$ 629.35