CIST 1305
Unit 07 Drop Box Assignment
The Assignment
ONLY ONE FILE may be turned in for the assignment. If you make a
mistake and need to turn
in your work again, you may do so. I will only grade the latest
file you turn in. The older ones
will be ignored. For instruction on How To do assignments and
create the file see the "How To
Do Homework" document under the "Start Here" button.
You will create a word processing document and create a psuedocode
solution to the following
problem.
The code in the pseudocode on the following page contains two
methods, main() and
retrieveProdName(num n). The main() method calls the
retrieveProdName() method using a
number read from the users input at the keyboard. This psudocode
design was implemented
in Java, and deployed to the customer’s machines. But occasionally
the program throws an
InvalidPIDException and crashes. This is very disturbing to the
customer, and they are
demanding a fix. Your job is fix this problem.
First study the code to see how it work and determine where the
exception can be thrown.
Then copy the main() pseudocode (no need to copy the
retrieveProdName() method as you
will not be changing it) and apply a fix. The fix will consist of
your using try and catch blocks
to catch the exception. When the exception is caught print out an
"Invalid Product Code,
please try again" message, and then allow the program to continue
normally.
What to turn in
At the top of your document make sure you put your name, date, and
"CIST 1305 Unit 07
Lab". You then will enter your fixed main() method only in your
document, no need to write
out the other method, you did not change it. You can save your
document for your own use
in any format you like. Name your paper "Unit07_Lab_<your first
initial><your last
name>.xxx". Where xxx is the file extension your word processor
uses. So Tom Swift (who
used Word) would name his file Unit01_Lab_tswift.docx.
But, create a PDF document to turn in. So Tom's document to turn in
would be named
Unit07_Lab_tswift.pdf. All modern word processors can create a PDF
file by use of a "Save
As ..." dialog or an "Export..." dialog usually found under the
"File" menu. If you are not sure
how to export a PDF Google it to find out. If that does not help
post to our HELP discussion
board.
import java.util.*;
import java.lang.*;
import java.io.*;
class Test
{
/* I have designed this function to generate a
Exception
to test main method is handling the exception or
not.
You can remove this method if need to submit in
assignment*/
//Declaring retrieveProdName method to throw a
exception for us
static void retrieveProdName(int num) throws
Exception{
throw new Exception("demo");
}
public static void main (String[] args)
{
try {
/* We suspect that this block of statement can throw
exception */
retrieveProdName(5);
}
catch (Exception e) {
/* This is a generic Exception handler which means it
can handle all the exceptions. */
System.out.println("Invalid Product Code, please try
again");
/*
If want to print that exception you can use following
statement
System.out.println("Exception occured is: "+ e);
*/
}
System.out.println("Continuing
normal flow...");
}
}
CIST 1305 Unit 07 Drop Box Assignment The Assignment ONLY ONE FILE may be turned in for the assig...
CIST 1305 Unit 06 Drop Box Assignment General Instructions You will create a word processing document and save it in "PDF" format. If you turn your document in using the wrong format, you will get no credit for it. ONLY ONE FILE may be turned in for the assignment. If you make a mistake and need to turn in your work again, you may do so. I will only grade the latest file you turn in. The older ones will...
/************************************************************************************ * Program: PRG/420 Week 5 * Purpose: Week 5 Coding Assignment * Programmer: TYPE YOUR NAME HERE * Class: PRG/420 * Creation Date: TYPE TODAY'S DATE HERE ************************************************************************************* * Program Summary: * This program converts a given date to a string. * The code includes exception handling for a ParseException. ************************************************************************************/ package prg420week5_codingassignment; import java.util.*; // wildcard to import all the util. classes import java.text.*; // wildcard to import all the text classes public class PRG420Week5_CodingAssignment { public static...
Consider the data file “assignment-07-input.csv. The data contains of 4 different things separated by comma – origin airport code (3 characters), destination airport code (3 characters), airline code (2 characters), passenger count (integer). There is no header row, so you do not have to deal with it. Write code to do the following: • The program will take 3 extra command line arguments & use a makefile to run. o Input file name o Output file name o Airline code...
create a new Java application called "CheckString" (without the quotation marks) according to the following guidelines. ** Each method below, including main, should handle (catch) any Exceptions that are thrown. ** ** If an Exception is thrown and caught, print the Exception's message to the command line. ** Write a complete Java method called checkWord that takes a String parameter called word, returns nothing, and is declared to throw an Exception of type Exception. In the method, check if the...
Unit 1 Programming Assignment Follow the directions for each of the following questions. Answer the question or provide the code in a space below the question. 1. Write the complete script tag set for a script whose line statement is document.write(“Hello, world.”); 2. Build a complete HTML document and include the answer to the previous question such that the page executes the script as the page loads. Open the document in your browser to test the results. 3. Add a...
Trying to practice this assignment Argument list: the *yahoonews.txt Data file: yahoonews.txt Write a program named WordCount.java, in this program, implement two static methods as specified below: public static int countWord(Sting word, String str) this method counts the number of occurrence of the word in the String (str) public static int countWord(String word, File file) This method counts the number of occurrence of the word in the file. Ignore case in the word. Possible punctuation and symbals in the file...
I need help with my homework assignment Linux systems keep user account information in the passwd file and the encrypted password in the shadow file. The passwd file containing account information might look like this: smithj:x:1001:1001:John Smith:/home/smithj:/bin/bash The shadow file containing password and account expiration information for users might look like this: smithj:KJDKKkkLLjjwlnttqoiybnm.:10063:0:99999:7::: The fields in the shadow file are separated by a colon, with the first field being the username and the second being the password. Under normal circumstances,...
Your mission in this programming assignment is to create a Python program that will take an input file, determine if the contents of the file contain email addresses and/or phone numbers, create an output file with any found email addresses and phone numbers, and then create an archive with the output file as its contents. Tasks Your program is to accomplish the following: ‐ Welcome the user to the program ‐ Prompt for and get an input filename, a .txt...
CIST 2371 Introduction to Java Unit 03 Lab Due Date: ________ Part 1 – Using methods Create a folder called Unit03 and put all your source files in this folder. Write a program named Unit03Prog1.java. This program will contain a main() method and a method called printChars() that has the following header: public static void printChars(char c1, char c2) The printChars() method will print out on the console all the characters between c1 and c2 inclusive. It will print 10...
CSC151 JAVA PROGRAMMING LAB #7 OBJECTIVES . . . In this lab assignment, students will learn: To get an overview of exceptions and exception handling • To explore the advantages of using exception handling • To declare exceptions in a method header • To throw exceptions in a method • To write a try-catch block to handle exceptions To develop applications with exception handling To use the finally clause in a try-catch block To write data to a file using...