Answer:
See Explaination
Explanation:
// for generating random numbers import java.util.Random; // read and write to a file and handling exceptions import java.io.*; // reading data from a file import java.util.Scanner; // storing data into ArrayList import java.util.ArrayList; class Sample { int[] arr; public int[] generateSales() { // creating an object for Random class Random r = new Random(); // creating an array of size 10 arr = new int[10]; for(int i=0;i<arr.length;i++) { // generating random numbers and storing into an array arr[i] = r.nextInt(100); } for(int i=0;i<arr.length;i++) { // printing the array data in console System.out.println(arr[i]); } // returning integer array return arr; } // Writing to a file public String writeToFile(int[] tarr) { // fName for storing file name String fName = null; // try-catch for catching any unwanted exception try { File file = new File("numbers.txt"); // file.createNewFile() creates the file if(file.createNewFile()) { System.out.println("File created Successfully"); } // if file exists else block will be executed else { System.out.println("File already exists'"); } // storing the filename fName = file.getName(); FileWriter myWriter = new FileWriter(fName); for(int i=0; i<tarr.length;i++) { // writing to a file myWriter.write(arr[i]+"\n"); } // closing the file myWriter.close(); System.out.println("Successfully wrote to the file."); } catch (IOException e) { System.out.println("An error occurred."); e.printStackTrace(); } // returning the file name return fName; } // reading data from a file public ArrayList<Integer> readNumbers(String fileName) { // ArrayList to store integer type data ArrayList<Integer> list = new ArrayList<Integer>(); // try-catch to handle FileNotFoundException try { File f = new File(fileName); // reading data from a file Scanner sc = new Scanner(f); while (sc.hasNextInt()) { // storing data into a list list.add(sc.nextInt()); } // closing the file sc.close(); } catch (FileNotFoundException e) { System.out.println("An error occurred."); e.printStackTrace(); } // returning ArrayList return list; } // Printing the data of ArrayList to console public void printResults(ArrayList<Integer> intList) { for(int i=0;i<intList.size();i++) { System.out.println(intList.get(i)); } } // main method public static void main(String[] args) { ArrayList<Integer> listOInt = new ArrayList<Integer>(); // creating an object for Sample class Sample s = new Sample(); int[] rarr; // calling generateSales method and storing the returned int array rarr = s.generateSales(); // calling writeToFile method and storing the returned fileName String fileName = s.writeToFile(rarr); // calling readNumbers method and storing the returned ArrayList listOInt = s.readNumbers(fileName); // calling printResults to display the data of listOInt s.printResults(listOInt); } }
Answer:
the answer to the fill-in is <em>project. </em>
Explanation:
Answer:
Option B is the correct answer for the above question.
Explanation:
The control structure is a decision type structure which can be either true or false. It has two options-- If this then, does this otherwise do this. When the user wants to write he control structure then he can do this by the help of the following syntax in python language--
if(condition):
do this
else:
do this
The above question wants to ask about the concept which is used in the programming for a decision then the answer is control structure which is referred from the option B. Hence B is the correct option while the other is not because--
- Option A states about the flowchart which is the picture form of the instruction.
- Option C states about the pseudocode which is the language form of the instruction.
- The operator is also not the correct option because it is used to perform the operation.
Answer: Stubs, data flow analysis, capture-replay tools and mock object are useful during the system testing.
Explanation:
Stubs hold the predefined data and used it to answer calls during testing. Stub act as an object and test scrub simulated the charactertics of software components.
Data flow analysis used in the programming of software components by using the control flow graph. It basically focused on the data variable and their definite values. It is used in the form of whitepox testing.
Capture replay tool is used as aggression development test and during testing it records all the events. By using playback it also compared the results in the testing.
Mock object are used to verified all the expected results and behavior during testing. Mock objects are mainly used in unit testing.
Answer:
def feet_to_inches( feet ):
inches = feet * 12
print(inches, "inches")
feet_to_inches(10)
Explanation:
The code is written in python. The unit for conversion base on your question is that 1 ft = 12 inches. Therefore,
def feet_to_inches( feet ):
This code we define a function and pass the argument as feet which is the length in ft that is required when we call the function.
inches = feet * 12
Here the length in ft is been converted to inches by multiplying by 12.
print(inches, "inches")
Here we print the value in inches .
feet_to_inches(10)
Here we call the function and pass the argument in feet to be converted