1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
SashulF [63]
3 years ago
8

Write a program that first calls a function to calculate the square roots of all numbers from 1 to 1,000,000 and write them to a

file named: roots.txt (See output on page 3) 2.) Write a program then calls a function to calculate the squares of all numbers from 1 to 1,000,000 and write them to a file named: squares.txt 3.) Here are the function prototypes: void writeRoots(); void writeSquares();
Computers and Technology
1 answer:
svlad2 [7]3 years ago
3 0

Answer:

The csharp program to compute square roots of numbers and write to a file is as follows.

class Program  

{  

static long max = 1000000;  

static void writeRoots()  

{  

StreamWriter writer1 = new StreamWriter("roots.txt");  

double root;  

for (int n=1; n<=max; n++)  

{  

root = Math.Sqrt(n);  

writer1.WriteLine(root);  

}  

}  

static void Main(string[] args)  

{  

writeRoots();  

}  

}

The program to compute squares of numbers and write to a file is as follows.

class Program  

{  

static long max = 1000000;  

static void writeSquares()  

{  

StreamWriter writer2 = new StreamWriter("squares.txt");  

long root;  

for (int n = 1; n <= max; n++)  

{  

root = n*n;  

writer2.WriteLine(root);  

}  

}  

static void Main(string[] args)  

{  

writeSquares();  

}  

}  

Explanation:

1. An integer variable, max, is declared to hold the maximum value to compute square root and square.

2. Inside writeRoots() method, an object of StreamWriter() class is created which takes the name of the file as parameter.

StreamWriter writer1 = new StreamWriter("roots.txt");

3. Inside a for loop, the square roots of numbers from 1 to the value of variable, max, is computed and written to the file, roots.txt.

4. Similarly, inside the method, writeSquares(), an object of StreamWriter() class is created which takes the name of the file as parameter.

StreamWriter writer2 = new StreamWriter("squares.txt");

5. Inside a for loop, the square of numbers from 1 to the value of the variables, max, is computed and written to the file, squares.txt.

6. Both the methods are declared static.

7. Inside main(), the method writeRoots() and writeSquares() are called in their respective programs.

8. Both the programs are written using csharp in visual studio. The program can be tested for any operation on the numbers.

9. If the file by the given name does not exists, StreamWriter creates a new file having the given name and then writes to the file using WriteLine() method.

10. The csharp language is purely object-oriented language and hence all the code is written inside a class.

You might be interested in
Write a loop that reads strings from standard input where the string is either "land", "air", or "water". The loop terminates wh
Setler79 [48]

The loop terminates when "xxxxx" is read in. If the word is land, the string followed by "land" get outputted. The same with air, and water.

Explanation:

int land = 0;

int air = 0;

int water = 0;

String word = "";

while(!(word.equals("xxxxx"))) {

word = stdin.next();

if(word.equals("land")) {

   land++;

}else if(word.equals("air")) {

   air++;

}else if(word.equals("water")) {

   water++;

}  

}

System.out.println("land:" + land);

System.out.println("air:" + air);

System.out.println("water:" + water);

5 0
3 years ago
What are the 49 questions for creat and edit Excel assessment​
castortr0y [4]

Answer:

1. What is the keyboard shortcut key to lock cell references in a formula

2. What are the shortcut keys for Auto Sum?

3. What are the shortcut keys to insert a new row in an Excel spreadsheet?

4. What are the shortcut keys to group rows so you can expand/contract a section of data?

5. Which of the following Excel features allows you to select/highlight all cells that are formulas?

6. What are the keyboard shortcut keys to paste special?

7. Assuming cell A1 is displaying the number "12000.7789". What formula should be used to round this number to the closest integer?

8. What are the keyboard shortcut keys to edit formula in a cell?

9. What are the keyboard shortcut keys to insert a table?

10. In which tab of the ribbon can you change Workbook Views to Page Break Preview?

11. What is the best practice for financial modeling in excel?

12. Which of the following features cannot be found in the Data ribbon?

13. The shortcut keys to increase the number of decimal places are

14. What are the shortcut keys to open up the Find and Replace window?

15. Which tab of the ribbon should you go to for removing grid lines on a worksheet?

16. What is a cell address in Excel?

17. What do you mean by Relative cell referencing and Absolute cell referencing in MS Excel?

18. How can you restrict someone from copying a cell from your worksheet?

19. How is a Formula different from a Function in Excel?

20. Mention the order of operations used in Excel while evaluating formulas.

21. What is the difference between count, counta, and countblank?

22. What is the shortcut to add a filter to a table?

23. How can we merge multiple cells text strings in a cell?

24. How many report formats are available in Excel?

25. What is a Pivot Table?

26. How do you find duplicate values in a column?

27. How can you remove duplicate values in a range of cells?

28. What are the wildcards available in Excel?

29. What is Data Validation? Illustrate with an example.

30. How do you create a column in a pivot table?

31. How does a Slicer work in Excel?

32. What are macros in Excel?

33. What is the What-If Analysis in Excel?

34. What is the difference between a function and a subroutine in VBA?

35. What is the difference between This Workbook and Active Workbook in VBA?

36. How do we check whether a file exists or not in a specified location?

37. Write a VBA function to calculate the area of a rectangle.

38. Write a VBA function to check if a number is a prime number or not.

Explanation:

I think these questions are enough for you.

4 0
2 years ago
When comparison shopping, all of these hint at a good deal EXCEPT_____________________.
pav-90 [236]

Answer:

lower-priced models offer more features

Explanation:

4 0
3 years ago
Indicates how fast the engine is moving in rpms.
lapo4ka [179]
That would be called a <span>tachometer </span>
7 0
3 years ago
To insert an endnote, which steps should you follow?
Evgesh-ka [11]
<span>To insert an endnote, you should follow he following steps:
A.Place the cursor in the document where you want the note reference mark to appear, select Insert Endnote command from the Reference tab in the Footnotes group.
Correct answer: A
</span><span>This way a reference mark would be added in the text and the endnote will be added at the end of the document.</span>
6 0
3 years ago
Other questions:
  • Suppose company A wants to develop a program that duplicates the functionality of a programm by company B. Describe how company
    8·1 answer
  • Define a function CoordTransform() that transforms the function's first two input parameters xVal and yVal into two output param
    12·1 answer
  • This program has some errors in it that are needed to be checked import java.io.*;
    13·1 answer
  • What is one property of a good hash code?
    11·1 answer
  • Suppose I create a new kind of Java object, called "Kangaroo". Further suppose that at any given time, all instances of this new
    6·1 answer
  • Write a program that prompts the user to enter two characters and display the corresponding major and year status. The first cha
    15·1 answer
  • What is the next line?
    8·1 answer
  • is a measurement that quantifies how much information can be transmitted over the network. A. Memory B. DMZ C. Bandwidth D. Clou
    10·1 answer
  • Write long answer to the following question. a. Define microcomputer. Explain the types of microcomputers in detail.​
    5·2 answers
  • consider a pipelined risc cpu with 14 stages. what is maximum speedup of this cpu over a non-pipelined implementation?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!