Two C++ assignments and easy works by using Codeblcoks as simple code as you ca

Two C++ assignments and easy works by using Codeblcoks as simple code as you ca

Problem G1

This program will read integers from a file and find results from these integers.

Open the file, test to make sure the file opened. Use a loop to read the integers and process each integer as it is read. When End Of File is reached, close the file.

After all of the integers have been read and processed, print the results for the following output:

  • The integer count:
  • The sum of the integers:
  • The smallest integer:
  • The largest integer:
  • The average of the integers:

Use notepad, vim, or other simple text editor to create a file named file1.txt containing the following, with one integer per line.

Test the program two times.

Use the following data in the first test:

11_x000D_
9_x000D_
18_x000D_
22_x000D_
27_x000D_
33_x000D_
21_x000D_
  

For the second test add an additional line containing the number 40.

Problem G2

Provide a loop with a menu. Repeat until the user selects quit. Prompt the user to select one of the menu items. Test for numbers that are not in the menu, provide an error message, and then continue. The menu shall contain:

1. Square   pattern_x000D_
2. Triangle pattern_x000D_
3. Diagonal pattern_x000D_
4. Reverse diagonal pattern_x000D_
5. Quit_x000D_
  

After the user selects a pattern, allow them to specify the size. If the size is smaller than 1 or larger than 9, give them an error message and repeat the specification of the size.

Once the user has correctly selected a pattern and a size, print the pattern using the size specified.

Pattern 1 is a square. Example for size 4:

4444_x000D_
4444_x000D_
4444_x000D_
4444_x000D_
  

Pattern 2 is a triangle. Example for size 5:

5_x000D_
55_x000D_
555_x000D_
5555_x000D_
55555_x000D_
  

Pattern 3 is a square with a diagonal of numbers in stars. Example for size 6:

6*****_x000D_
*6****_x000D_
**6***_x000D_
***6**_x000D_
****6*_x000D_
*****6_x000D_
  

Pattern 4 is a square with a reversed diagonal of numbers in stars. Example for size 7:

******7_x000D_
*****7*_x000D_
****7**_x000D_
***7***_x000D_
**7****_x000D_
*7*****_x000D_
7******_x000D_
  

Test the program once using each of these values in order:
Pattern 9; when that is rejected try:
Pattern 1, size 11; when that is rejected use:
Pattern 1, size 3
Pattern 2, size 4
Pattern 3, size 5
Pattern 4, size 6

Quit

"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.


Discount Code: CIPD30



Click ORDER NOW..

order custom paper