Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Module 4 Assignment Criteria For this assignment, you will process a large dataset. A university posts its employees’ salaries at liveexample.pearsoncmg.com/data/Salary.txt. Each line in the file...

1 answer below »
Module 4 Assignment Criteria
For this assignment, you will process a large dataset. A university posts its employees’ salaries at liveexample.pearsoncmg.com/data/Salary.txt. Each line in the file consists of a faculty member’s first name, last name, rank, and salary (see Programming Exercise 12.24).
1. Create pseudo-code for this project
2. Write a program to display the total salary for assistant professors, associate professors, full professors, and all faculty, respectively, and display the average salary for assistant professors, associate professors, full professors, and all faculty, respectively.
After running your program, the results should look similar to the image below.

Once finished, zip your project folder and upload to the dropbox. Don’t forget to include your pseudocode.








Module 5 Assignment Criteria
For this assignment, you will generate and display a pie chart.
1. Write pseudo-code for the project.
2. Write a program that uses a pie chart to display the percentages of the overall grade represented by projects, quizzes, midterm exams, and the final exam, as shown in the image below.
a. Projects take 20 percent and are displayed in red.
. Quizzes take 10 percent and are displayed in blue.
c. Midterm exams take 30 percent and are displayed in green.
d. Final exams take 40 percent and is displayed in orange.
3. Use the Arc class to display the pie slices. If interested, you may explore JavaFx’s PieChart class for additional study.

Once finished, zip your project folder and upload to the dropbox. Don’t forget to include your pseudocode.







Chapter 13 Exception Handling
Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved.
*
Chapter 12 Exception Handling and Text IO
*
Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved.
*
Motivations
When a program runs into a runtime e
or, the program terminates abnormally. How can you handle the runtime e
or so that the program can continue to run or terminate gracefully? This is the subject we will introduce in this chapter.



Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved.
*
Objectives
    To get an overview of exceptions and exception handling (§12.2).
    To explore the advantages of using exception handling (§12.2).
    To distinguish exception types: E
or (fatal) vs. Exception (nonfatal) and checked vs. unchecked (§12.3).
    To declare exceptions in a method header (§12.4.1).
    To throw exceptions in a method (§12.4.2).
    To write a try-catch block to handle exceptions (§12.4.3).
    To explain how an exception is propagated (§12.4.3).
    To obtain information from an exception object (§12.4.4).
    To develop applications with exception handling (§12.4.5).
    To use the finally clause in a try-catch block (§12.5).
    To use exceptions only for unexpected e
ors (§12.6).
    To rethrow exceptions in a catch block (§12.7).
    To create chained exceptions (§12.8).
    To define custom exception classes (§12.9).
    To discover file/directory properties, to delete and rename files/directories, and to create directories using the File class (§12.10).
    To write data to a file using the PrintWriter class (§12.11.1).
    To use try-with-resources to ensure that the resources are closed automatically (§12.11.2).
    To read data from a file using the Scanner class (§12.11.3).
    To understand how data is read using a Scanner (§12.11.4).
    To develop a program that replaces text in a file (§12.11.5).
    To read data from the Web (§12.12).
    To develop a Web crawler (§12.13).
*
Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved.
*
Exception-Handling Overview
Show runtime e
o
Fix it using an if statement
With a method
Run
Quotient
Run
QuotientWithIf
Run
QuotientWithMethod
*
Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved.
*
Exception Advantages
Now you see the advantages of using exception handling. It enables a method to throw an exception to its caller. Without this capability, a method must handle the exception or terminate the program.
Run
QuotientWithException
*
Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved.
*
Handling InputMismatchException
By handling InputMismatchException, your program will continuously read an input until it is co
ect.
Run
InputMismatchExceptionDemo
*
Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved.
*
Exception Types
IllegalArgumentException
Many more classes
Many more classes
Many more classes
IndexOutOfBoundsException
NullPointerException
ArithmeticException
Object
RuntimeException
Exception
IOException
VirtualMachineE
o
ClassNotFoundException
Throwable
E
o
LinkageE
o
Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved.
*
System E
ors
System e
ors are thrown by JVM and represented in the E
or class. The E
or class describes internal system e
ors. Such e
ors rarely occur. If one does, there is little you can do beyond notifying the user and trying to terminate the program gracefully.
IllegalArgumentException
Many more classes
Many more classes
Many more classes
IndexOutOfBoundsException
NullPointerException
ArithmeticException
Object
RuntimeException
Exception
IOException
VirtualMachineE
o
ClassNotFoundException
Throwable
E
o
LinkageE
o
Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved.
*
Exceptions
Exception describes e
ors caused by your program and external circumstances. These e
ors can be caught and handled by your program.
IllegalArgumentException
Many more classes
Many more classes
Many more classes
IndexOutOfBoundsException
NullPointerException
ArithmeticException
Object
RuntimeException
Exception
IOException
VirtualMachineE
o
ClassNotFoundException
Throwable
E
o
LinkageE
o
Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved.
*
Runtime Exceptions
RuntimeException is caused by programming e
ors, such as bad casting, accessing an out-of-bounds a
ay, and numeric e
ors.
IllegalArgumentException
Many more classes
Many more classes
Many more classes
IndexOutOfBoundsException
NullPointerException
ArithmeticException
Object
RuntimeException
Exception
IOException
VirtualMachineE
o
ClassNotFoundException
Throwable
E
o
LinkageE
o
Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved.
*
Checked Exceptions vs. Unchecked Exceptions
RuntimeException, E
or and their subclasses are known as unchecked exceptions. All other exceptions are known as checked exceptions, meaning that the compiler forces the programmer to check and deal with the exceptions.
Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved.
*
Unchecked Exceptions
In most cases, unchecked exceptions reflect programming logic e
ors that are not recoverable. For example, a NullPointerException is thrown if you access an object through a reference variable before an object is assigned to it; an IndexOutOfBoundsException is thrown if you access an element in an a
ay outside the bounds of the a
ay. These are the logic e
ors that should be co
ected in the program. Unchecked exceptions can occur anywhere in the program. To avoid cumbersome overuse of try-catch blocks, Java does not mandate you to write code to catch unchecked exceptions.
Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved.
*
Unchecked Exceptions
Unchecked exception.
IllegalArgumentException
Many more classes
Many more classes
Many more classes
IndexOutOfBoundsException
NullPointerException
ArithmeticException
Object
RuntimeException
Exception
IOException
VirtualMachineE
o
ClassNotFoundException
Throwable
E
o
LinkageE
o
Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved.
*
Declaring, Throwing, and Catching Exceptions
method1() {
try {
invoke method2;
}
catch (Exception ex) {
Process exception;
}
}
method2() throws Exception {
if (an e
or occurs) {
throw new Exception();
}
}
catch exception
throw exception
declare exception
Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved.
*
Declaring Exceptions
Every method must state the types of checked exceptions it might throw. This is known as declaring exceptions.
public void myMethod()
throws IOException
public void myMethod()
throws IOException, OtherException
Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved.
*
Throwing Exceptions
When the program detects an e
or, the program can create an instance of an appropriate exception type and throw it. This is known as throwing an exception. Here is an example,
throw new TheException();
TheException ex = new TheException();
throw ex;
Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved.
*
Throwing Exceptions Example
/** Set a new radius *
public void setRadius(double newRadius)
throws IllegalArgumentException {
if (newRadius >= 0)
radius = newRadius;
else
throw new IllegalArgumentException(
"Radius cannot be negative");
}
Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved.
*
Catching Exceptions
try {
statements;
Statements that may throw exceptions
}
catch (Exception1 exVar1) {
handler for exception1;
}
catch (Exception2 exVar2) {
handler for exception2;
}
...
catch (ExceptionN exVar3) {
handler for exceptionN;
}
Liang, Introduction to Java Programming, Eleventh Edition, (c) 2017 Pearson Education, Inc. All rights reserved.
*
Catching Exceptions
main method {
...
try {
...
invoke method1;
statement1;
}
catch (Exception1 ex1) {
Process ex1;
}
statement2;
}
method1 {
...
try {
...
invoke method2;
statement3;
}
catch (Exception2 ex2) {
Process ex2;
}
statement4;
}
Call Stack
An exception is thrown in method3
method2 {
...
try {
...
invoke method3;
statement5;
}
catch
Answered Same Day Apr 01, 2021

Solution

Amit answered on Apr 03 2021
131 Votes
38219/Module 4/pseudocode.docx
The required pseudo-code is as given below:
1. Start.
2. Import all required java packages in the program.
3. Create the class “Salary”, so that average salary based on provided ranks from the database can be displayed.
4. Make declaration of required variables in the program which are used for different calculations.
5. Create URL for reading data from provided link.
6. Make use of while loop for calculating average salary of all professors based on their ranks.
7. Display the total and average salary for the professors.
8. End.
38219/Module 4/salary/.classpath

    
    
    
38219/Module 4/salary/.project

     salary
    
    
    
    
        
             org.eclipse.jdt.core.javabuilde
            
            
        
    
    
         org.eclipse.jdt.core.javanature
    
38219/Module 4/salary/.settings/org.eclipse.jdt.core.prefs
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.4
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
org.eclipse.jdt.core.compiler.source=1.3
38219/Module 4/salary
in/Salary.class
public synchronized class Salary {
public void Salary();
public static void main(String[]) throws Exception;
}
38219/Module 4/salary/output.PNG
38219/Module 4/salary/src/Salary.java
38219/Module...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here