Machine Problem 8 How To Implement Exception and Assertion
Machine Problem 8 How To Implement Exception and Assertion
CCS0023L
(Object Oriented Programming)
Machine Problem
8
How to implement exception and assertion
Student Name:
Guballa, Ramon Chino L.
Section:
1-A
Professor:
Doc Kirk Awat
I.
This study source was downloaded by 100000831283672 from CourseHero.com on 10-27-2022 22:49:17 GMT -05:00
https://www.coursehero.com/file/72609695/Machine-Problem-8-How-to-implement-exception-and-assertiondocx/
Create a Class FindArray that will try to iterate in the array displaying the content
in each index. The program should be able to catch an
ArrayIndexOutOfBoundsException, a NullPointerException and a RunTimeException.
package main3;
import java.util.InputMismatchException;
import java.util.Scanner;
/**
*
* @author chinoguballa
*/
public class Main3 {
package main3;
This study source was downloaded by 100000831283672 from CourseHero.com on 10-27-2022 22:49:17 GMT -05:00
https://www.coursehero.com/file/72609695/Machine-Problem-8-How-to-implement-exception-and-assertiondocx/
/**
*
* @author chinoguballa
*/
public class NumberToWord {
static {
private static final String[] specialNames = {
"",
" thousand",
};
https://www.coursehero.com/file/72609695/Machine-Problem-8-How-to-implement-exception-and-assertiondocx/
if (number % 100 < 20){
current = numNames[number % 100];
number /= 100;
}
else {
current = numNames[number % 10];
number /= 10;
if (number < 0) {
number = -number;
prefix = "negative";
}
do {
int n = number % 1000;
if (n != 0){
String s = toWord(n);
current = s + specialNames[place] + current;
}
place++;
number /= 1000;
} while (number > 0);
This study source was downloaded by 100000831283672 from CourseHero.com on 10-27-2022 22:49:17 GMT -05:00
https://www.coursehero.com/file/72609695/Machine-Problem-8-How-to-implement-exception-and-assertiondocx/
This study source was downloaded by 100000831283672 from CourseHero.com on 10-27-2022 22:49:17 GMT -05:00
https://www.coursehero.com/file/72609695/Machine-Problem-8-How-to-implement-exception-and-assertiondocx/
Powered by TCPDF (www.tcpdf.org)