Summation Notation: T(n) = Σ(i=0 to n-1)Σ(j=i+1 to n-1)1 = (n-1)(n-2)/2 = O(n^2)
Instruction Count Method: T(n) = 3n + 2(n-1)(n-2)/2 = (3n + n^2 - 3n -2)/2 = O(n^2)
What is time complexity ?
Time complexity is the measure of how long it takes for an algorithm or program to execute and complete its task. It is typically expressed in terms of the amount of time required to complete a program as a function of the size of the input. In other words, the time complexity of an algorithm is the amount of time it takes to run a certain number of instructions for a given input size. Time complexity can help determine the efficiency of an algorithm and can also be used to compare different algorithms for the same problem.
To know more about time complexity
https://brainly.com/question/28014440
#SPJ4
Why must the image be reduced when the field of view is widened to take in more of the scene?
Type the correct answer in the box. Spell all words correctly.
John wants to use graphical elements on his web page. Which image formats should he use to keep the file size manageable?
John should use
formats to keep the file size manageable.
Answer:
PNG, GIF
Explanation:
What is the most efficient solution to keep personal and work emails separate, even if they are in a single email box
Separate your emails into different folders. adding filters to your email accounts is a smart idea because they will automatically sort your emails into the correct folder. Using a strategy like this will help you stay organized and make managing many email accounts much easier.
What is email ?
Email, or electronic mail, is a communication technique that sends messages via electronic devices across computer networks. The term "email" can apply to both the method of delivery and the specific messages that are sent and received.
Since Ray Tomlinson, a programmer, invented a mechanism to send messages between computers on the Advanced Research Projects Agency Network in the 1970s, email has existed in some form (ARPANET). With the introduction of email client software (like Outlook) and web browsers, which allow users to send and receive messages via web-based email clients, modern versions of email have been widely accessible to the general public.
To know more about Email, check out:
https://brainly.com/question/28802519
#SPJ1
What is lossy compression
A. It is a technique that results in the loss of all files on a computer.
B. It is a technique that reduces the file size by permanently removing some data
C. It is a method of combining the memories of the ram and the rom
D. It is a method that stores data dynamically requiring more power
Answer:
B. It is a technique that reduces the file size by permanently removing some data
Answer:
B. It is a technique that reduces the file size by permanently removing some data
Explanation:
Explain expansion bus
Answer:
okay here
Explanation:
An expansion bus is an assortment of wires that allows for computer expansion with the use of an expansion board, a printed circuit board inserted into an expansion slot on the motherboard or backplane that provides additional features to a computer system.
The expansion bus is a collection of cables that facilitates the growth of a computer system by operating an expansion board, or by using a backplane, which facilitates the evolution of a computer system. In addition, the computer system will also be provided with additional features.
Hope this helps :)
How can presentation software be used in a
business or professional setting? Choose all that
apply.
to automate the ticket-purchasing process at
movie theaters through a kiosk
to teach lessons to high school students
to deliver a sales presentation to clients
to create charts and graphs from a table of
values
to compose letters and memos
DONE
Answer:
To automate the ticket purchasing process at the movie theaters through a kiosk
To teach lessons to high school students
To deliver a sales presentation to clients
Explanation:
I just used the answers above and got 2/3 wrong and edge said so
A laser printer uses...........
A. Correction fluid
B. Ink cartridge
C. Photocopy ink
D. Toner cartridge
Answer:
Toner cartridge
Explanation:
Need an answer in Python
Write a program for. checking the truth of the statement ¬(X ⋁ Y ⋁ Z) = ¬X ⋀ ¬Y ⋀ ¬Z for all predicate values.
Using the knowledge in computational language in python it is possible to write a code that checking the truth of the statement ¬(X ⋁ Y ⋁ Z) = ¬X ⋀ ¬Y ⋀ ¬Z for all predicate values.
Writting the code:def conjunction(p, q):
return p and q
print("p q a")
for p in [True, False]:
for q in [True, False]:
a = conjunction(p, q)
print(p, q, a)
def exclusive_disjunction(p, q):
return (p and not q) or (not p and q)
print("p q a")
for p in [True, False]:
for q in [True, False]:
a = exclusive_disjunction(p, q)
print(p, q, a)
See more about python at brainly.com/question/18502436
#SPJ1
Using a K-Map, simplify the sum of the minterms.
Karnaugh Map or K-Map is a pictorial method used to simplify Boolean algebra expressions and produce a minimized version of a given truth table and the simplified expression is D(B+AC)+D(AC+C) + BD.
Karnaugh Map or K-Map is a grid-like representation of truth tables that enables the user to identify patterns that correspond to logical operations of the Boolean variables.
K-Maps are useful tools for simplifying Boolean expressions.
They provide a graphical method of representing a Boolean function's truth table that simplifies the process of reducing the function using Boolean algebra.
The following steps are used to simplify the sum of the minterms using K-Map:
Construct the K-Map. In this case, since the function is a sum of minterms, we are given that the output is high whenever A=0, B=1, C=0, D=0, A=1, B=1, C=0, D=0, A=0, B=1, C=1, D=0, A=1, B=1, C=1, D=0, A=1, B=0,C=1, D=1, and A=0, B=1, C=1, D=1.
These are the cells with 1 in the map.
Group the adjacent cells containing 1s in groups of 2, 4, or 8.
Convert the groupings into Boolean expressions.
Simplify the expressions by using Boolean algebra.
The K-Map for the given sum of minterms, the two groups can be converted into Boolean expressions as follows:
Group 1: BD+ACD+ABCD
Group 2: AC+BD+BCD
Simplify the Boolean expressions by using Boolean algebra.
Group 1: BD + ACD + ABCD = D (B+AC+ABC)
= D(B+AC)
Group 2: AC + BD + BCD = D(AC+B+C) + BD = D(AC+B+C+B)
= D(AC+C)
The simplified expression is D(B+AC)+D(AC+C) + BD.
For more questions on Karnaugh Map:
https://brainly.com/question/27873494
#SPJ8
A method signature for a method consists of all elements of the method except the body. That is, a method signature consists of the privacy, (non-)static, return datatype, method name, and formal parameters. Consider the ceiling method as an example.
public static int ceiling (double num)
{
return num <= 0 ? (int) num: (int) num + 1;
}
The method signature of the ceiling method is the first line of the method: public static int ceiling (double num). In this example, we note that ceiling is static because it is a standalone method and does not require an object to invoke (since we are not acting on an instance of a class).
For parts a - d, give the method signature described by the scenario.
a) A method in class String that returns the reversed version of the current String.
b) A method that returns the maximum of two given integers.
c) A method that returns true or false if the input integer is an even number.
d) A default constructor for class Table.
Answer this is it right here
Which page does a site map usually begin with?
A.shop Page B.Home page C.Index page D.About Page
Answer:
home page
Explanation:
a sitemap is a file where you provide information about the pages, videos, and other files on your site, and the relationships between them
Good information is characterized by certain properties. Explain how you understand these characteristtics of good information. Use examples to better explain your answer.
Answer:
here is your ans
Explanation:
Characteristics of good quality information can be defined as an acronym ACCURATE. These characteristics are interrelated; focus on one automatically leads to focus on other.
Accurate
Information should be fair and free from bias. It should not have any arithmetical and grammatical errors. Information comes directly or in written form likely to be more reliable than it comes from indirectly (from hands to hands) or verbally which can be later retracted.
Complete
Accuracy of information is just not enough. It should also be complete which means facts and figures should not be missing or concealed. Telling the truth but not wholly is of no use.
Cost-beneficial
Information should be analysed for its benefits against the cost of obtaining it. It business context, it is not worthwhile to spend money on information that even cannot recover its costs leading to loss each time that information is obtained. In other contexts, such as hospitals it would be useful to get information even it has no financial benefits due to the nature of the business and expectations of society from it.
User-targeted
Information should be communicated in the style, format, detail and complexity which address the needs of users of the information. Example senior managers need brief reports which enable them to understand the position and performance of the business at a glance, while operational managers need detailed information which enable them to make day to day decisions.
Relevant
Information should be communicated to the right person. It means person which has some control over decisions expected to come out from obtaining the information.
Authoritative
Information should come from reliable source. It depends on qualifications and experience and past performance of the person communicating the information.
Timely
Information should be communicated in time so that receiver of the information has enough time to decide appropriate actions based on the information received. Information which communicates details of the past events earlier in time is of less importance than recently issued information like newspapers. What is timely information depends on situation to situation. Selection of appropriate channel of communication is key skill to achieve.
Easy to Use
Information should be understandable to the users. Style, sentence structure and jargons should be used keeping the receiver in mind. If report is targeted to new-comer in the field, then it should explain technical jargons used in the report.
Question 2 of 25
How could a video's file size be reduced so that it will take up less space on a
computer's hard drive?
A. By shooting it at a lower resolution
B. By shooting it at a higher resolution
C. By shooting it at a higher frame rate
D. By sampling the sound at the maximum rate
Q. Which of the following would a PC repair technician work on?
answer choices
Application code
Smartphone screen
Laptop
Server
The following option that refers to the function or job description of a PC repair technician work on is C. Laptop. It is because PC refers to the multi-purpose microcomputer, so the following option that suitable is laptop.
In computer and technology, A technician generally can be defined as a worker in a field of technology, who is proficient in the relevant skill and technique, with a relatively practical understanding of the theoretical principles. Beside that, A personal computer or also known as PC generally can be defined as a multi-purpose microcomputer whose size, capabilities, and price make it feasible for individual use.
Here you can learn more about personal computer https://brainly.com/question/28716381
#SPJ4
Performance assessments are conducted periodically and .
Performance assessments are conducted periodically and systematically.
What are performance assessments ?Periodic and structured evaluations are essential to maintain accurate assessments of performance. These reviews usually occur regularly, such as once or twice a year, and follow a systematic process designed to examine an individual's job-related skills consistently using objective standards.
A typical appraisal procedure generally includes establishing clear aims and goals for the employee, offering regular coaching along with feedback throughout the appraisal term, compiling data related to their task progress, and then conducting a comprehensive review at the end of that period to analyze and assess it thoroughly.
Find out more on performance assessments at https://brainly.com/question/1532968
#SPJ1
During the course of execution of a program, the processor will increment the contents of the instruction register (program counter) by one word after each instruction fetch, but will alter the contents of that register if it encounters a branch or call instruction that causes execution to continue elsewhere in the program. There are two alternatives with respect to instruction addresses:
a. Maintain a relative address in the instruction register and do the dynamic address translation using the instruction register as input. When a successful branch or call is encountered, the relative address generated by that branch or call is loaded into the instruction register .
b. Maintain an absolute address in the instruction register. When a successful branch or call is encountered, dynamic address translation is employed, with the results stored in the instruction register
Describe the impact of a company’s culture on its success in a customer-focused business environment. Discuss why each is important.
The influence of a corporation's culture cannot be underestimated when it comes to achieving success in a customer-centric commercial landscape.
The values, beliefs, norms, and behaviors that constitute a company's culture have a major impact on how its employees engage with customers and prioritize their requirements.
Having a customer-centric mindset means cultivating a culture that places a strong emphasis on satisfying and prioritizing customers' needs and desires, resulting in employees who are aware of the critical role customer satisfaction plays in ensuring success.
Learn more about company’s culture from
https://brainly.com/question/16049983
#SPJ1
4) Create a text file (you can name it sales.txt) that contains in each line the daily sales of a company for a whole month. Then write a Java application that: asks the user for the name of the file, reads the total amount of sales, calculates the average daily sales and displays the total and average sales. (Note: Use an ArrayList to store the data).
Answer:
Here's an example Java application that reads daily sales data from a text file, calculates the total and average sales, and displays the results:
import java.util.ArrayList;
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
public class SalesDemo {
public static void main(String[] args) {
// Ask the user for the name of the file
Scanner input = new Scanner(System.in);
System.out.print("Enter the name of the sales file: ");
String fileName = input.nextLine();
// Read the daily sales data from the file
ArrayList<Double> salesData = new ArrayList<>();
try {
Scanner fileInput = new Scanner(new File(fileName));
while (fileInput.hasNextDouble()) {
double dailySales = fileInput.nextDouble();
salesData.add(dailySales);
}
fileInput.close();
} catch (FileNotFoundException e) {
System.out.println("Error: File not found!");
System.exit(1);
}
// Calculate the total and average sales
double totalSales = 0.0;
for (double dailySales : salesData) {
totalSales += dailySales;
}
double averageSales = totalSales / salesData.size();
// Display the results
System.out.printf("Total sales: $%.2f\n", totalSales);
System.out.printf("Average daily sales: $%.2f\n", averageSales);
}
}
Assuming that the sales data is stored in a text file named "sales.txt" in the format of one daily sale per line, you can run this program and input "sales.txt" as the file name when prompted. The program will then calculate the total and average sales and display the results.
I hope this helps!
Explanation:
If any one has mincraft on ps4 bedrock we can finish building a BIG city world all we need to put is a shop and money dispensers thx
Answer:
cool i want a ps5
Explanation:
Fiverr Sellers have many advantages when managing Buyer expectations, like setting
The Fiverr Sellers have many advantages when managing Buyer's expectations like setting fixed prices. Thus, correct option is C.
What are Buyer's Expectations?Fiverr is the world's largest marketplace for digital services. It offers both sellers and buyers a platform for streaming digital transactions. In this platform, sellers get a unique service called 'Gig' where they can choose the starting price of their product and service.
On this platform, buyers pay sellers for fulfilling the services. Fiverr can take commission for initiating any work. For working as a seller, one needs to give detailed information about oneself.
By fixing the amount of service and product, sellers can manage the buyer's expectations which helps in increasing their business and making profit.
Therefore, C is the correct option.
Learn more about Internet Marketing here:
https://brainly.com/question/28425124
#SPJ1
Your question is incomplete, probably the complete question/missing part is:
Fiverr Sellers have many advantages when managing Buyer expectations, like setting
Choose Only One Best Answer.
A. Much Higher Rates For Low-Quality Work.
B. Prices That Could Change At Any Time.
C. Fixed Prices
D. The Lowest Freelance Rates Across The Market.
Write a program that reads the student information from a tab separated values (tsv) file. The program then creates a text file that records the course grades of the students. Each row of the tsv file contains the Last Name, First Name, Midterm1 score, Midterm2 score, and the Final score of a student. A sample of the student information is provided in StudentInfo.tsv. Assume the number of students is at least 1 and at most 20.
The program performs the following tasks:
Read the file name of the tsv file from the user. Assume the file name has a maximum of 25 characters.
Open the tsv file and read the student information. Assume each last name or first name has a maximum of 25 characters.
Compute the average exam score of each student.
Assign a letter grade to each student based on the average exam score in the following scale:
A: 90 =< x
B: 80 =< x < 90
C: 70 =< x < 80
D: 60 =< x < 70
F: x < 60
Compute the average of each exam.
Output the last names, first names, exam scores, and letter grades of the students into a text file named report.txt. Output one student per row and separate the values with a tab character.
Output the average of each exam, with two digits after the decimal point, at the end of report.txt. Hint: Use the precision sub-specifier to format the output.
Ex: If the input of the program is:
StudentInfo.tsv
and the contents of StudentInfo.tsv are:
Barrett Edan 70 45 59
Bradshaw Reagan 96 97 88
Charlton Caius 73 94 80
Mayo Tyrese 88 61 36
Stern Brenda 90 86 45
the file report.txt should contain:
Barrett Edan 70 45 59 F
Bradshaw Reagan 96 97 88 A
Charlton Caius 73 94 80 B
Mayo Tyrese 88 61 36 D
Stern Brenda 90 86 45 C
Averages: midterm1 83.40, midterm2 76.60, final 61.60
ChodeHS Exercise 4.3.5: Coin Flips
Write a program to simulate flipping 100 coins. Print out the result of every flip (either Heads or Tails).
At the end of the program, print out how many heads you flipped, how many tails you flipped, what percentage were heads, and what percentage were tails.
Answer:
public class CoinFlips extends ConsoleProgram
{
public static final int FLIPS = 100;
public void run()
{
int countH = 0;
int countT = 0;
for(int i = 0; i < 100; i++)
{
if (Randomizer.nextBoolean())
{
System.out.println("Heads");
countH += 1;
}
else
{
System.out.println("Tails");
countT += 1;
}
}
System.out.println("Heads: " + countH);
System.out.println("Tails: " + countT);
System.out.println("% Heads: " + (double) countH / FLIPS);
System.out.println("% Tails: " + (double) countT / FLIPS);
}
}
Explanation:
First define your counting variables for both heads and tails (I named them countH and countT). Set them to 0 at the start of the run.
Then use a for loop to flip the coin 100 times. In the video you should have learned about the Randomizer class so you can use the same idea to print out whether you got heads or tails.
Make sure to keep the count going using >variable name< += 1.
The printing at the end is very basic; print the statement for each: ("Heads: " + >variable name<);
For the percentages, print ("% Heads: " + (double) >variable name< / FLIPS); divided by FLIPS (not 100 or any other int because you will get the wrong value) and remember to cast them as doubles to get the correct value.
The program simulates 100 coin flips and displays the result of each flip and the resulting percentage. The program written in python 3 goes thus :
import random
#import the random module
total = 0
#initialize the total coin flips
h_count = 0
t_count = 0
#initialize variable to hold the number of heads and tails
h_t = ['h', 't']
#define the sample space
while total < 100 :
#keeps track that tosses does not exceed 100
toss = random.sample(h_t, 1)
#variable to hold the outcome of each coin toss
if toss[0] == 'h':
#heck if toss is head
h_count+=1
Increase count of heads. owee
print(toss[0], end=' ')
#display the sample selected
else:
#if not head, then it's tail
t_count+=1
#increase count yv
print(toss[0], end=' ')
total+=1
#
print('head counts : ', h_count, 'percentage : ', round(h_count/100, 2),'%')
print('tail counts : ', t_count, 'percentage : ', round(t_count/100, 2), '%')
# display result.
A sample run of the program is attached
Learn more: https://brainly.com/question/18581972
In this lab, you complete a C++ program that swaps values stored in three int variables and determines maximum and minimum values. The C++ file provided for this lab contains the necessary variable declarations, as well as the input and output statements. You want to end up with the smallest value stored in the variable named first and the largest value stored in the variable named third. You need to write the statements that compare the values and swap them if appropriate. Comments included in the code tell you where to write your statements.InstructionsEnsure the Swap.cpp file is open in your editor.Write the statements that test the first two integers, and swap them if necessary.Write the statements that test the second and third integer, and swap them if necessary.Write the statements that test the first and second integers again, and swap them if necessary.Execute the program by clicking the "Run Code" button at the bottom of the screen using the following sets of input values.101 22 -23630 1500 921 2 2Provided code:// Swap.cpp - This program determines the minimum and maximum of three values input by// the user and performs necessary swaps.// Input: Three int values.// Output: The numbers in numerical order.#include using namespace std;int main(){ // Declare variables int first = 0; // First number int second = 0; // Second number int third = 0; // Third number int temp; // Used to swap numbers const string SENTINEL = "done"; // Named constant for sentinel value string repeat; bool notDone = true; //loop control // Get user input cout << "Enter first number: "; cin >> first; cout << "Enter second number: "; cin >> second; cout << "Enter third number: "; cin >> third; while(notDone == true){ // Test to see if the first number is greater than the second number // Test to see if the second number is greater than the third number // Test to see if the first number is greater than the second number again // Print numbers in numerical order cout << "Smallest: " << first << endl; cout << "Next smallest: " << second << endl; cout << "Largest: " << third << endl; cout << "Enter any letter to continue or done to quit: "; cin >> repeat; if (repeat == SENTINEL){ notDone = false; } else { cout << "Enter first number: "; cin >> first; cout << "Enter second number: "; cin >> second; cout << "Enter third number: "; cin >> third; } return 0;} // End of main function
Answer:
Following are the code to the given question:
#include <iostream>//header file
using namespace std;
int main()//main method
{
int first = 0,second = 0,third = 0;//defining integer variable
int temp; //defining integer variable
const string SENTINEL = "done"; // defining a string variable as constant
string repeat;// defining a string variable
bool notDone = true; //defining bool variable
cout << "Enter first number: ";//print message
cin >> first;//input value
cout << "Enter second number: ";//print message
cin >> second;//input value
cout << "Enter third number: ";//print message
cin >> third;//input value
while(notDone == true)//defining a loop to check the value
{
if(first > second)//use if to compare first and second value
{
int temp = first;//defining temp to hold first value
first = second;//holding second value in first variable
second = temp;//holding temp value in second variable
}
if(second > third)//use if to compare second and third value
{
int temp = second;//defining temp to hold second value
second = third;//holding second value in third variable
third = temp;//holding temp value in third variable
}
cout << "Smallest: " << first << endl;//print smallest value
cout << "Next smallest: " << second << endl;//print Next smallest value
cout << "Largest: " << third << endl;////print Largest value
cout << "Enter any letter to continue or done to quit: ";//print message
cin >> repeat;//holding string value
if (repeat == SENTINEL)
{
notDone = false;//holding bool value
}
else //else block
{
cout << "Enter first number: ";//print message
cin >> first;//input value
cout << "Enter second number: ";//print message
cin >> second;//input value
cout << "Enter third number: ";//print message
cin >> third;//input value
}
return 0;
}
}
Output:
Please find the attached file.
Explanation:
Inside the main method Four integer variable "first, second, third, and temp" is declared in which first three variable is used for input value and temp is used to compare value. In thew next step, two string variable "SENTINEL and repeat" is declared in which "SENTINEL" is constant and a bool variable "notDone" is declared. After input the value from the user-end a loop is declared that compare and swap value and print its value.
Havc parts 2 what is a TXV
Answer:
It's a metering duives
Explanation:
Answer:
The Thermal Expansion Valve (TXV) is an important piece of equipment in the HVAC industry. The valve is used to control the amount of refrigerant released to the evaporator section. The TXV Expansion valves reside between the evaporator and condenser in the refrigeration cycle
Explanation:
just look it up :)
What is an automatic update and when should you use it
define the term Scenario
Answer:
a postulated sequence or development of events.
Which of these is the largest?
terabyte
exabyte
gigabyte
kilobyte
PLEASE HELP
Answer: Exabyte
Explanation:
I took the Quiz
JAVA A user will enter an initial number, followed by that number of integers. Output those integers' sum. Repeat until the initial number is 0 or negative. Ex: If the user enters 3 9 6 1 0, the output is:
The program illustrates the use of repetitive operations.
Repetitive operations are done by using loops such as while and for loops
The program in Java, where comments are used to explain each line is as follows:
import java.util.*;
public class Main{
public static void main(String[] args) {
//This declares all required variables
int num,total = 0;
//This creates a Scanner object
Scanner input = new Scanner(System.in);
//This gets the initial input
num= input.nextInt();
//The following is repeated until the initial input is 0 or less
while(num > 0){
//This is repeated to get integer inputs
for(int i = 0;i<num;i++){
//This adds up all integer inputs
total+=input.nextInt();
}
//This prints the total inputs
System.out.println(total);
//This initializes total to 0
total = 0;
//This gets the initial input
num= input.nextInt();
}
}
}
The loop will be executed as long as initial input is a positive integer.
See attachment for sample run.
Read more about similar programs at:
https://brainly.com/question/14072658
Write a program that reads a file name from the keyboard. The file contains integers, each on a separate line. The first line of the input file will contain the number of integers in the file. You then create a corresponding array and fill the array with integers from the remaining lines. If the input file does not exist, give an appropriate error message and terminate the program. After integers are stored in an array, your program should call the following methods in order, output the intermediate results and count statistics on screen, and at end output even integers and odd integers to two different files called even.out and odd.out.
Implement the following methods in the program:
* public static int[] inputData() – This method will ask user for a file name, create an array, and store the integers read from the file into the array. If input file does not exist, give an appropriate error message and terminate the program.
* public static void printArray(int[] array) – This method will display the content of the array on screen. Print 10 integers per line and use printf method to align columns of numbers.
public static void reverseArray(int[] array) – This method will reverse the elements of the array so that the 1st element becomes the last, the 2nd element becomes the 2nd to the last, and so on.
* public static int sum(int[] array) – This method should compute and return the sum of all elements in the array.
* public static double average(int[] array) – This method should compute and return the average of all elements in the array.
* public static int max(int[] array) – This method should find and return the largest value in the array.
* public static int min(int[] array) – This method should find and return the smallest value in the array.
* public static void ascendingSelectionSortArray(int[] array) – This method will use Selection Sort to sort (in ascending order) the elements of the array so that the 1st element becomes the smallest, the 2nd element becomes the 2nd smallest, and so on.
* public static void desendingBubbleSortArray(int[] array) – This method will Bubble Sort to sort (in descending order) the elements of the array so that the 1st element becomes the largest, the 2nd element becomes the 2nd largest, and so on.
* public static void outputData(int[] array) – This method will create two output files called even.out and odd.out. Scan through the entire array, if an element is even, print it to even.out. If it is odd, print the element to odd.out.
Answer:
Explanation:
import java.util.Scanner;
import java.io.*;
public class ArrayProcessing
{
public static void main(String[] args) throws IOException
{
Scanner kb = new Scanner(System.in);
String fileName;
System.out.print("Enter input filename: ");
fileName = kb.nextLine();
File file = new File(fileName);
if(!file.exists())
{
System.out.println("There is no input file called : " + fileName);
return;
}
int[] numbers = inputData(file);
printArray(numbers);
}
public static int[] inputData(File file) throws IOException
{
Scanner inputFile = new Scanner(file);
int index = 1;
int size = inputFile.nextInt();
int[] values = new int[size];
while(inputFile.hasNextInt() && index < values.length)
{
values[index] = inputFile.nextInt();
index++;
}
inputFile.close();
return values;
}
public static void printArray(int[] array)
{
int count = 1;
for (int ndx = 1; ndx < array.length; ndx++)
{
System.out.printf("%5.f\n", array[ndx]);
count++;
}
if(count == 10)
System.out.println("");
}
}