I will post The following below1. Assignment 2 Rubric requirements2. Design notes.3. Assignment 1 of another studentread the following an perform as mentioned . and comment on every changes that were made ..
assingnment_2_requirments.png

design_notes_.docx

ali_assignment1.java.zip

Unformatted Attachment Preview

Design notes of Ali
1. How do you think you would add file reading and writing functionality to your menu program,
Answer:
We should create two methods for reading and writing respective. Each method will call based
on the what user select on the menu.
When program show the menu for user select one of them, list of option should included the
option for reading file and writing file.
In each method, the program should ask the user for name file need to read or need to write.
When user select the option reading file, after asked them for name file, the program will create a
file with this name and then check if it existed or not. If this file not existed, the program will
show the message error for user and then ask they select again. If the file existed, the program
will open file and reading file. Also, show the content of file.
For the option writing file, the program will do the same for ask file name and check if it existed
or not then show error if not existed. If the file existed, the program open the file and ready
writing. The program ask user for text need be write to file.
After reading writing finish, the program need close the file.
2. Describe how you think the try-catch feature of Java work and what exactly the
FileNotFoundException class is,
Answer:
The try-catch is used to enclose the code that might throw an exception and handle the Exception. It
must be used within the method. If exception is handled by the application programmer, normal flow
of the application is maintained i.e. rest of the code is executed. Each catch block is an exception
handler that handles the type of exception indicated by its argument. The argument type,
ExceptionType, declares the type of exception that the handler can handle and must be the name of
a class that inherits from the Throwable class. The handler can refer to the exception with name.
The catch block contains code that is executed if and when the exception handler is invoked. The
runtime system invokes the exception handler when the handler is the first one in the call stack whose
ExceptionType matches the type of the exception thrown. The system considers it a match if the
thrown object can legally be assigned to the exception handler’s argument.
Exception handlers can do more than just print error messages or halt the program. They can do error
recovery, prompt the user to make a decision, or propagate the error up to a higher-level handler using
chained exceptions.
The FileNotFoundException class is handle for code block do open a file failed. The file with the
specified pathname does not exist. It will also be thrown by these constructors if the file does exist but
for some reason is inaccessible, for example when an attempt is made to open a read-only file for
writing.
3. Identify sections of your code that you could create automated reusable methods out of,
Answer:
Sections of code could create automated reusable method out of is:


Show the menu:
System.out.println(“nMenu: “);
System.out.println(“1 – Name of the file”);
System.out.println(“2 – Text to write in to file”);
System.out.println(“3 – Number”);
System.out.println(“Q – Quit”);
System.out.print(“Select: “);
Generate list of number in range [1-100]
int[] total = new int[10];
//init value
for(int i = 0; i < 10; i++) total[i] = 0; //generate 1000 random number in range 1 - 100 System.out.println("Generating 1000 random numbers in range 1 - 100"); Random rand = new Random(); int i = 0; while(i < 1000) { int randomNum = rand.nextInt((100 - 1) + 1) + 1; if(randomNum <= 10) total[0]++; else if(randomNum <= 20) total[1]++; else if(randomNum <= 30) total[2]++; else if(randomNum <= 40) total[3]++; else if(randomNum <= 50) total[4]++; else if(randomNum <= 60) total[5]++; else if(randomNum <= 70) total[6]++; else if(randomNum <= 80) total[7]++; else if(randomNum <= 90) total[8]++; else if(randomNum <= 100) total[9]++; i++; } - Print the output for totally of each sub range [1-10],[11-20], [21-30],[31-40], [41-50],[51-60], [61-70],[71-80], [81-90],[91-100]. System.out.println("Generated 1000 random numbers in range 1 - 100"); System.out.println("The number in range [1-10] is: "+total[0]); System.out.println("The number in range [11-20] is: "+total[1]); System.out.println("The number in range [21-30] is: "+total[2]); System.out.println("The number in range [31-40] is: "+total[3]); System.out.println("The number in range [41-50] is: "+total[4]); System.out.println("The number in range [51-60] is: "+total[5]); System.out.println("The number in range [61-70] is: "+total[6]); System.out.println("The number in range [71-80] is: "+total[7]); System.out.println("The number in range [81-90] is: "+total[8]); System.out.println("The number in range [91-100] is: "+total[9]); 4. What are a couple ways that we could document our processes (design, test, implementation, communicate, reflect), Answer: To document our processes, we can use design, implementation and test. 5. Design tests that should show that your program works correctly (positive tests and negative tests), Answer: In the project 1, we implement a program show the menu for user select such as: Enter file name, enter text, ask user enter the number in range 1-10. So we have tests as below: - - - Select enter the name file and then output this name file back. Ex: enter: “Project2.docx” then the program will print back same file name “Project2.docx”. If the program print the file name not same mean that program working incorrectly. Enter the text and print back. Ex: enter: “Here is the second program” then the program will print back same text “Here is the second program”. If the program print the text not same mean that program working incorrectly. Enter the number greater than 0 and smaller than 11. The program will show the message that this number in range [1-10]. If enter the number greater than 10 or smaller than 1, the program will print the message that the number entered not in range [1-10]. Ex: Enter “0” then the program will display “The number entered not in range [1-10]”. Enter “5” then the program will display “The number entered in range [1-10]”. 6. Create a bullet list of the parts of class so far that are difficult, try to explain why you think they are difficult, and mention ways that we might make them easier to understand or work with. Answer: A class in Java included Variable, Methods. For each variable, we need get method and set method the value of it. We need more method to do details of request. It difficult for us when use type of access these variables, we need know what variable don’t allow change the value and what variable can change from out of class. To make them easier to understand or work with we need determine what type of value of class can change outside of class and what cannot change outside of class. What method the other class can use or call. And need make sure other function called the method of class do not change the value of variable member of class. ... Purchase answer to see full attachment