Question
Some of the class here have already answered but I needed the code asap implementing the exception for Factorial and Address Book. Only NetBeans project
Some of the class here have already answered but I needed the code asap implementing the exception for Factorial and Address Book.
Only NetBeans project compressed in .rar or .zip format will be accepted.
Catching Exceptions
Implement Exception handling for the programs you have written in the laboratory exercises as listed below. Note that all data to be used for processing must be input data (data entry from the user). When an invalid data is entered, the program should loop back to data entry until the input becomes valid.
Lab Exercise 004 Factoria
Lab Exercise 007 Address Book
I don't have a code for Factorial but I request for the code implementing exception.
Even the instruction says specifically for negative values, I also needed the code for any invalid input like letters etc.
Here is my code for Address Book without implementing exception:
package lab7_nunez_maryaileen;
import java.util.Scanner;
class AddressBook { //attributes private String Name;//Name of the person in the address book private String Address;//Address of the person private String Mobile_Number;//Mobile number of the person private String Email_Address;//Email address of the person //constructors AddressBook() { } AddressBook(String n,String a,String m,String e) { Name = n; Address = a; Mobile_Number = m; Email_Address = e; } //Accessors String get_Name() { return Name; } String get_Address() { return Address; } String get_Mobile_Number() { return Mobile_Number; } String get_Email_Address() { return Email_Address; } //mutators void set_Name(String n) { Name=n; } void set_Address(String a) { Address=a; } void set_Mobile_Number(String m) { Mobile_Number=m; } void set_Email_Address(String e) { Email_Address=e; } }
package lab7_nunez_maryaileen;
import java.util.Scanner; public class AddressBookTest { public static void main(String argv[]) { AddressBook book[] = new AddressBook[100];//Instantiating an array of AddressBook objects of 100 entries for(int i=0;i
System.out.print("Enter Mobile number of the person:"); s =sc.next(); book[n].set_Mobile_Number(s); System.out.print("Enter Email address of the person:"); s =sc.next(); book[n].set_Email_Address(s); size++; n++;
} else if(c==2 && size !=0)//checking entry added or not { int m; s=""; System.out.print("Enter index to delete :"); m = sc.nextInt(); book[n].set_Name(s); book[n].set_Address(s); book[n].set_Mobile_Number(s); book[n].set_Email_Address(s); size--; } else if(c==3&& size !=0) { int i; System.out.println(" Entries in book:"); for(i=0;i System.out.print("Enter Name of the person in the address book :"); s =sc.next(); book[m].set_Name(s); System.out.print("Enter Address of the person:"); s =sc.next(); book[m].set_Address(s); System.out.print("Enter Mobile number of the person:"); s =sc.next(); book[m].set_Mobile_Number(s); System.out.print("Enter Email address of the person:"); s =sc.next(); book[m].set_Email_Address(s); } else if(c==5) { System.out.println(" Thank you......."); break; } else { System.out.println(" Enter Correct Choice "); } } } } Thank you so much to someone who will answer the question :)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started