Write a c# program in Microsoft visual studio to determine if the following numbers are even or not.
Create an app that will read integers from an input file name Number.txt that will consist of one integer.
Determine which numbers are even and which are odd. Write the even numbers to a file named Even.txt and the odd numbers to a file named Odd.txt.
Number.txt
20
39
45
12
31
62
10
11
21
73
14
42
55
86
109
200
13
25
38
64
Here is code:
using System;
using System.IO;
namespace ConsoleApp // Project name
{
class Program
{
static void Main(string[] args)
{
StreamWriter swEven = new StreamWriter("Even.txt", false);
StreamWriter swOdd = new StreamWriter("Odd.txt", false);
using (StreamReader sr = new StreamReader("Number.txt"))
{
string line;
// Read and display lines from the file until
// the end of the file is reached.
while ((line = sr.ReadLine()) != null)
{
if (int.Parse(line) % 2 == 0)
{
swEven.WriteLine(line);
}
else
{
swOdd.WriteLine(line);
}
}
}
Console.WriteLine("Done");
swEven.Close();
swOdd.Close();
Console.ReadKey();
}
}
}
Number.txt:
20
39
45
12
31
62
10
11
21
73
14
42
55
86
109
200
13
25
38
64
Even.txt:
20
12
62
10
14
42
86
200
38
64
Odd.txt:
39
45
31
11
21
73
55
109
13
25
Write a c# program in Microsoft visual studio to determine if the following numbers are even...
(C++ Microsoft Visual Studio) [15 Points] Write a while loop to calculate the average of numbers entered by the user: Ask the user to enter an integer number or -1 to stop Add the entered numbers Compute the average of the numbers outside the loop after termination Print the average
in a c++ visual studio 2017 ...Write a program that simulates a lottery. The program should have an array of five integers named lottery and should generate a random number in the range 0 through 9 for each element in the array. The user should enter five digits, which should be stored in an integer array named user. The program is to compare the corresponding element in the two arrays and keep a count of the digits that match. For...
Must be done in C++ 2013 microsoft visual studio Write a program that creates a 4 x 5 two-dimensional array. The program should use loops to populate the array using the rand, srand and time functions with random numbers between 10 and 60. After the values have populated the array, output the values of the array to the screen in something that looks like a 4 x 5 table.
using Microsoft Visual Studio C++ write a compute program that will allow the user to: 1.Get a Factorial (using a loop) 2. perform addition and subtraction 3.allow the user to quit the program
programming in Microsoft visual studio. Write a C++ program for the following algorithm. Compile, run, and verify the result by choosing some test data. Prompt user to write X1 value in double Read X1 Prompt user to write X2 value in double Read X2 Prompt user to write Y1 value in double Read Y1 Prompt user to write Y2 value in double Read Y2 Compute the lengths of the two sides of the right triangle generated by the two points...
Write an encryption and decryption program that displays properly in Microsoft Visual Studio using c++. Encrypt each digit by adding 7 and taking the remainder after division by 10. After encrypting each digit, swap the first and third then swap the second and fourth. Decryption should reverse the process. Program must input a single integer. Program must do encode and decode in one file. Example Program Session (yours must look like this): Encode (1) Decode (2): 1 Enter...
C++ and Using Microsoft Visual Studio. Write 2 programs: One program will use a structure to store the following data on a company division: Division Name (East, West, North, and South) Quarter (1, 2, 3, or 4) Quarterly Sales The user should be asked for the four quarters' sales figures for the East, West, North, and South divisions. The data for each quarter for each division should be written to a file. The second program will read the data written...
This program should use a main function and two other functions named playlist and savelist as follows: The main function: The main function should create an empty list named nums and then use a loop to add ten integers to nums, each integer in the range from 10-90. NOTE: In Python, a list is a data type. See Chapter 7. The main function should then call the playlist function and savelist function, in that order. Both of these functions take...
Write a program using C in Microsoft visual studios. Write a function that receives an array of integers and the array length and prints one integer per line (Hint: Use \n for a line break). Left align all of the integers and use a field width of 10. Populate an array of 10 elements from the user and pass the array and its length to the function.
Write a C program to assign natural numbers 1 to 100 into a one-dimensional integer array. Display all the values in the array on the screen. For each number in the array, determine if the number contains digit 7 or is divisible by 7. Display all those numbers on the screen. Original array: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27...