The four methods needed for the assignment are specified in the Main class. Include a documentation comment with proper annotations for each of these four methods. Keep in mind that all four methods will be static and void. Additionally, there should be no throws clauses for any of the methods of this program. All exceptions should be properly handled with try-catch blocks. Refer to the following directions for each of the makeFile,readFile, writeFile, and deleteFile methods, respectively:
●Use the createNewFile() method of Java’s File class to add files to a subdirectory (folder)within the project directory. Let the user know if the file was successfully created or if anything goes wrong during the file creation process.
●Read from files using the Scanner class. Be sure to properly handle any exceptions inthe event that the file cannot be found or that the contents of the file cannot be read.Print the contents of the file to the console.
●Write to files using a combination of the FileWriter and PrintWriter classes. New content should be appended to the file rather than overwriting the current contents. Check that the file exists and throw an exception if it does not; do not rely on the PrintWriter class to create a new file to write to. Be sure to properly handle any exceptions in the event that the file cannot be found or that content cannot be written to the file.
●Use the delete() method of Java’s File class to delete files from the subdirectory. Let the user know if the file was successfully deleted or if anything goes wrong during the file deletion process.
The program used is Java script and requires two classes for the project, one- Main class and the second- FileHandler class. the File handler class should be able to create, read, write, and delete files.
public class Main
{
public static void main(String[] args)
{
Scanner keyboard = new
Scanner(System.in); // Scanner object to read user
input
String fileName = "";
// The name of a file to
perform actions on
String content = "";
// Content to be written to a
file
String line = "";
// An
individual line of content
int choice = -1;
// User's
selection
while (choice != 5)
{
System.out.println("1. Create a file\n2. Read from a file\n3. Write
to a file\n" +
"4. Delete a file\n5. Exit the program");
System.out.print("Please enter the number of your selection:
");
choice =
keyboard.nextInt();
keyboard.nextLine();
switch
(choice)
{
// Create a new file
case 1:
System.out.print("Please
enter the name of the new file: ");
fileName =
keyboard.nextLine();
FileHandler.makeFile(fileName);
break;
// Read from a file
case 2:
System.out.print("Please
enter the name of the file to read: ");
fileName =
keyboard.nextLine();
FileHandler.readFile(fileName);
break;
// Write to a file
case 3:
System.out.print("Please
enter the name of the file to write to: ");
fileName =
keyboard.nextLine();
line = "";
do
{
System.out.print("Please enter content to be added to the file
('end' to stop): ");
line =
keyboard.nextLine();
if
(!line.equals("end"))
content += line + "\n";
} while
(!line.equals("end"));
FileHandler.writeFile(fileName, content);
break;
// Delete a file
case 4:
System.out.print("Please
enter the name of the file to delete: ");
fileName =
keyboard.nextLine();
FileHandler.deleteFile(fileName);
break;
// Exit the program
case 5:
break;
// Warning for invalid input
default:
System.out.println("Please
enter a number from 1-5");
}
}
}
}
In: Computer Science
(I need an answer in c++ please / assignment question)
In a double linked chain, each node can point to the previous node as well as the next node.:
a. Define a class to represent a node in a doubly linked chain (UML)
b. Define a class to represent the doubly linked chain (UML), with operations such as:
1. finding its length.
2. add a new Node to the end of the chain.
3. check whether a given Node is included in the Chain (search a node)
4. another operation of your choice.
c. illustrate and list the steps to add to a node to the beginning of the doubly linked chain.
d. illustrate and list the steps necessary to remove the first noe from the doubly linked chain.
In: Computer Science
There's a fine line between white-hat and gray-hat hackers and between gray-hats and black-hats. For instance, some experts consider gray-hat hackers an essential part of securing the Internet because they often expose vulnerabilities before they're discovered by the security community. Research the "definitions" of each of these types of hackers and answer the following questions.
In: Computer Science
write in a long paragraph about the challenges in collecting, managing ,storing, querying, and analyzing various form of big data. use ur own words
In: Computer Science
(python only)
Assignment: Guess a number
To get started, open IDLE and create a New File via the File
menu. We suggest you immediately save this file in the directory
managing all your 102 Python Labs this semester. Please save this
file with the following name: Week9A-guess_number.py.
In this lab, use while loops to create a game where the user of your program guesses a number between 1 and 100. The user keeps guessing until they get it right. You should structure your program as follows:
NOTE: You must use a seed with your random number generator. This will make the grader's life WAY easier.
print("Number to initialize the random generator:")
my_seed = int(input("SEED> "))
random.seed(my_seed)
Sample Execution
Number to initialize the random generator: 32
Enter a number between 1 and 100: 95
OUTPUT You're cold!
Enter a number between 1 and 100: 105
OUTPUT Please Enter a number between 1 and 100
Enter a number between 1 and 100: 41
OUTPUT You're lukewarm!
Enter a number between 1 and 100: 32
OUTPUT You're getting warm!
Enter a number between 1 and 100: 16
OUTPUT You're getting hot!
Enter a number between 1 and 100: 9
OUTPUT You're so close!
Enter a number between 1 and 100: 10
OUTPUT Congrats! You won!
In: Computer Science
equilateral" when all the sides are equal and print "isosceles" when
two sides are equal and print "scalene" when all the sides are
different
In: Computer Science
State two reasons why it is advisable to place the transaction log on a separate disk device from the actual data?
In: Computer Science
( Posting the same question for third time. Can I please get answer in C++.( and not in C or Java) ..... Please Try and Provide me a complete programm Answer. not just one or two function)
* Declare a single dimensional array of 65 characters. Convert each character into an integer and store it in a linked list. Manipulate the linked list by completing the following task:
Create an additional linked list call greater_List, using the original linked list copy all number greater than 100 into the greater_list and give a total count of the numbers greater than 100. Create an additional array called less_array, copy all the numbers less than or equal to 100 in the original list into less_array give a total count of the numbers that are less than or equal to 100.
In: Computer Science
Write a Java program to do the following with your name. This can all be done in the main() method.
1. Create a String variable called myName and assign your personal name to it. Use proper capitalization for a legal name. I.e. String myName = "Billy Bob";
2. Load myName with the upper case version of itself and display the result.
3. Load myName with the lower case version of itself and display the result.
4. Capitalize the first letter of each given name in the lowercased name and display the result. Load the result into myName. Hint: This is not a single method call. You will need a loop to perform this. Hint: The substring method will be very helpful as you should likely build a new string result. Avoid magic number references. This solution should work with any proper name.
5. Using the value of the variable myName from step 4:
a.Display the Initials of the name. ( This may require a
Loop)
b.Use the trim methd on myName and store the results into
myName.
c.Display the size of the name
// Using Billy Bob as the name - here are the expected results:
My name in upper case is BILLY BOB.
My name in lower case is billy bob.
My name capitalized is Billy Bob.
My initials are BB.
The length of my name is 9.
In: Computer Science
Im writing a matlab script called vecadd that deals with vectors and is converting them between polar and rectangular coordinates. It is supposed to function based upon the following parameters:
vecadd adds two vectors and outputs the resultant vector.
vecadd(A,B) assumes A and B are both in rectangular form. The first element of each vector is the "x" component and the second element is the "y" component. The resultant is output in rectangular form.
vecadd(A,B,'p') assumes A and B are both in polar form. The first element of each vector is the magnitude and the second element is the angle in degrees. The resultant is output in polar form.
vecadd(A,B,'r') is equivalent to vecadd(A,B).
vecadd(A,B,'p','r') assumes A is in polar form and B is in rectangular form. vecadd(A,B,'r','p') assumes A is in rectangular form and B is in polar form. The resultant is output in rectangular form.
vecadd(A,B,'p','r','p') outputs the resultant in polar form.
vecadd(A,B,'p','r','r') is equivalent to vecadd(A,B,'p','r').
[RES, FORM] = vecadd(A,B,'p','r','p') outputs the resultant and the format of the resultant vector ('polar' if the last input argument is 'p' and 'rectangular' if the last input argument is 'r').
I need some help getting on the right track. Anything will do. Thanks
In: Computer Science
Write a program, using C#, windows forms, that will find the mean and standard deviation of a number of data points. The ONE PROGRAM should allow the user to enter data manually OR via a text file. The program should be very easy to use.
I will also need a step by step how to set up window for the answer. Please and thank you!!
In: Computer Science
In this lab, you will be completing a programming exercise through the point of view of both a
contracted library developer and the client that will use the developed code.
In the first part, you will be required to write a class in C++ that will be included in the client’s code.
Your class must be written with defensive programming in mind. It should allow the client to include or
leave out your defensive checks at compile-time.In the second part, you will use your defensively
programmed class methods to guide the revision of the provided user driver program. After
encountering failures from misuse of the library class methods, you will update the driver program,
according to the implementation guidelines in the CWE documentation for the appropriate error.
Note that the code you write does not have to be completely optimized and you will likely see better
ways to write the class and the driver to avoid the problems inherit in the client descriptions.
In Part 1 of the lab you will complete the following:
Write a class called myArray in a file named “yourlastname_lab2.cpp” where you substitute your
own name
o Constructor
two inputs: int size and string input
dynamically create a char* array of int size
parse string input (which should be a string of comma-separated characters)
and enter the characters in the array in order
o Destructor should free the memory assigned to your char* array
o ReadFromArray
one input: int index
return char at the given index for the array
o WriteToArray
two inputs: int index, char replace
overwrite char at given index with new char replace
o DeleteArray
free the memory for your char*
set char* to NULL
o PrintArray
output the contents of the char* array to stdout
o NewArray
two inputs: int size and string input
dynamically create a char* array of int size
parse string input (which should be a string of comma-separated characters)
and enter the characters in the array in order
For each class method, provide the contract for proper usage of the method
o enter as comment lines directly after the definition
o List any preconditions (what has to be true immediately before executing the method)o List any postconditions (what has to be true immediately after executing the method)
Utilize C standard assert() library calls from assert.h to test your preconditions
Use macros to give the client the option on whether to include the asserts at compile-time
Use the provided sample client driver program to test your class code
Take screenshots of your assertions being invoked for each function
In Part 2 of the lab you will complete the following:
• Using the assertions you have placed into your class methods, update the driver code to ensure
calls made to the class methods are in-contract
• Identify what CWE errors, if applicable, are occurring with out-of-contract use of your class
methods
• Review the ‘Potential Mitigation” section for those CWE errors and use the “Phase:
Implementation” entries to guide your revision of the provided program driver.
• Take screenshots of the driver code working without hitting the assertions – be sure to explain
in your word document how you tested the preconditions of each method and what changes
you made to the driver to ensure in-contract calls were made to the methods.
Graduate students should also answer the following:
• Is there a Python equivalent to the C-standard assert() calls used in class with C++?
• How would you approach defensive programming from the point-of-view of python methods?
Submit a zip file to Blackboard which contains your class file and a word document which includes the
screenshots and other information described above.
For full credit your code should compile, run as described, and be appropriately commented. If I need to
know anything in particular about how I should compile your code, include that in your document.
GIVEN cpp code:
============
//Sample client code for interfacing with myArray class
//Use this driver program to test your class and defensive
programming assertions
#include <iostream>
#include <string>
#include <stdlib.h>
#include "your_class_here.cpp" //replace this with your
own file
using namespace std;
int main(){
int size, choice, read, write;
string input;
char replace, response;
char * array;
cout << "Welcome, please enter a maximum size
for your array" << endl;
cin >> size;
cout << "Please enter a series of
comma-separated characters for your array" << endl;
cin >> input;
//create object of class type which should
dynamically allocate a char* array
//of int size and fill it with the comma-separated
values from string input
Array myArray(size, input);
while(1){
cout << "Array Menu"
<< endl;
cout << "1. Read by index"
<< endl;
cout << "2. Write by index"
<< endl;
cout << "3. Delete array"
<< endl;
cout << "4. Print array"
<< endl;
cout << "5. New Array"
<< endl;
cout << "6. Exit" <<
endl;
cin >> choice;
switch(choice){
case 1:
cout << "Enter an index to read a value from the array"
<< endl;
cin
>> read;
//call to library function ReadFromArray(int read)
//this library call should read a single character from the array
and return it
response = myArray.ReadFromArray(read);
cout << "The item in index[" << read << "] is "
<< response << endl;
break;
case 2:
cout << "Enter an index to write a value to the array"
<< endl;
cin
>> write;
cout << "What single character would you like to write to the
array?" << endl;
cin
>> replace;
//call to library function WriteToArray(int write, char
replace)
//this library call should write a single character to the
array
myArray.WriteToArray(write,replace);
cout << "The item in index[" << write << "] is "
<< myArray.ReadFromArray(write) << endl;
break;
case 3:
//call to library function DeleteArray() which should free the
dynamically allocated array
myArray.DeleteArray();
break;
case 4:
//call to library function PrintArray() which will print the
contents of the array to stdout
myArray.PrintArray();
break;
case 5:
//call to library function NewArray() which will dynamically
allocate a new array
cout << "Welcome, please enter a maximum size for your array"
<< endl;
cin
>> size;
cout << "Please enter a series of comma-separated characters
for your array" << endl;
cin
>> input;
myArray.NewArray(size, input);
break;
case 6:
exit(0);
break;
}
}
return 0;
}
In: Computer Science
Write an application for Lambert’s Vacation Rentals. Use separate ButtonGroups to allow a client to select one of three locations, the number of bedrooms, and whether meals are included in the rental. Assume that the locations are parkside for $600 per week, poolside for $750 per week, or lakeside for $825 per week. Assume that the rentals have one, two, or three bedrooms and that each bedroom over one adds $75 to the base price. Assume that if meals are added, the price is $200 more per rental. Save the file as JVacationRental.java.
This is also the 3rd time im gonna post it since all the answers im getting has a lot of errors so please help me
In: Computer Science
1
22
333
4444
55555
In: Computer Science
In the Monkey Illusion video, most people who have seen it before look for the gorilla but miss other changes such as a play in black leaving and the curtain changing color. https://youtu.be/IGQmdoK_ZfY
What is this phenomena called and explain why it occurs?
List a design implication of this (i.e., what do we have to keep in mind when designing products as a result of this propensity)?
In: Computer Science