Note: Could you plz go through this code and let me
know if u need any changes in this.Thank You
_________________
Input.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
_________________________
// ReadFileWriteFileDemo.java
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;
public class ReadFileWriteFileDemo {
public static void main(String[] args)
throws FileNotFoundException {
int nos[]=new int[20];
int i=0,evenSUm=0;
int prodOdd=1;
Scanner sc=new Scanner(new
File("Input.txt"));
while(sc.hasNext())
{
nos[i]=sc.nextInt();
i++;
}
sc.close();
for(int
j=0;j<nos.length;j++)
{
if(nos[j]%2==0)
{
evenSUm+=nos[j];
}
else
{
prodOdd*=nos[j];
}
}
PrintWriter pw=new PrintWriter(new
File("output.txt"));
for(int
j=0;j<nos.length;j++)
{
pw.write(nos[j]+" ");
}
pw.write("\n\n");
pw.write("Sum of even numbers
:"+evenSUm+"\n");
pw.write("Product of odd numbers
:"+prodOdd+"\n");
pw.close();
}
}
___________________________
// Outout.txt (Output file )
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Sum of even numbers :110
Product of odd numbers :654729075
_______________Could you plz rate me well.Thank
You
in Java and also follow rubric please 4. Write a complete program to do the following:...
Please Use C++ for coding
. . Note: The order that these functions are listed, do not reflect the order that they should be called. Your program must be fully functional. Submit all.cpp, input and output files for grading. Write a complete program that uses the functions listed below. Except for the printodd function, main should print the results after each function call to a file. Be sure to declare all necessary variables to properly call each function. Pay attention...
Write a complete program that uses the functions listed below. Except for the printOdd function, main should print the results after each function call to a file. Be sure to declare all necessary variables to properly call each function. Pay attention to the order of your function calls. Be sure to read in data from the input file. Using the input file provided, run your program to generate an output file. Upload the output file your program generates. •Write a...
Note: The order that these functions are listed, do not
reflect the order that they should be called. Your program must be
fully functional. Submit all .cpp, input and output files for
grading.
Write a complete program that uses the functions listed below.
Except for the printOdd function, main should print the results
after each function call to a file. Be sure to declare all
necessary variables to properly call each function. Pay attention
to the order of your function...
Exercise 4 Data rotation Write a program in C that reads from a file INFILE (you should create this file) a sequence of integer numbers. Consider that the length of the sequence is not knoun. Then, print to the file OUTFILE the sequence according to the following example: INFILE: 123456789 OUTFILE: 19 2 837465 The INFILE must be read only once!
Write a complete Java program, including comments in both the main program and in each method, which will do the following: 0. The main program starts by calling a method named introduction which prints out a description of what the program will do. This method is called just once. This method is not sent any parameters, and it does not return a value. The method should print your name. Then it prints several lines of output explaining what the...
Write a complete java program that prompts the user for their name and two numbers. The correct java methods and parameters must be passed to find the length of the name entered and return “TRUE” if the sum of numbers is even, or FALSE if the sum of numbers is odd: Notes included in the program Sample Program Please enter a name and I will tell you the length of the name entered John Then length of the name John...
2. Read in an unknown number of real values from a file called “data.txt”. Calculate the average of the real numbers. Output the average of the real numbers to a file called “output.txt”. Some skeleton code is provided for you below. #include int main (void) { FILE *infile = NULL; FILE *outfile = NULL; /* Fill in the code to open a file. Make sure you check that the file was open successfully. */ while (!feof (infile)) { /*...
•The multiplication operator works by summing some value, x, by another value, y. Write a function definition called multiply that takes two integer parameters to perform the operation described. Return the answer to the calling function. •Write a function called randCount with no parameters. The function should randomly generate 5 numbers between 8 to 15 and counts how many times a multiple of 2 occurred. Return the answer to the calling function. •Write a function called summary that takes as...
Write a function in the C++called summary that takes as its parameters an input and output file. The function should read two integers find the sum of even numbers, the sum of odd numbers, and the cumulative product between two values lower and upper. The function should return the sum of even, odd, ad cumulative product between the lower and upper values. Please write program in C++.
Write a program in C that creates an array of 100 random numbers from 0-99. The program sums the random numbers and prints the sum. It then writes the numbers to a new file using open, close and write. Then looks in the current directory for files that match the pattern “numbers.XXXX”. For each file, open the file and read the file. You can assume that the file will contain 100 integers. Sum the integers. Print the filename and the sum...