First program is attached. ————————————— Second progra

First program is attached.
—————————————
Second progra

First program is attached.
—————————————
Second program
Instruction for Chapter 7 Assignment
You are asked to create two input files as follow:
One file called names.txt consists of 10 names (first name last name) one per line
Another file called grades consists of 10 grades (87.50, …) one per line
Now write a program to read above files (name and grades) store them in two separate arrays. Names will be saved in an array of string, and grades will be saved in an array of integer or double.
After that, display data on screen. A sample out put looks like
Mark Jack-wiz 87.90
Antoni Zanzibar 89.50
Jacky Kano 89.50


———————————-
After program completion you will return to this area to submit your work as a Text Entry as well as File Upload (a .cpp file) as follows:
First, to submit your program as Text Entry, follow the steps below:Choose the Submit Assignment button (top right),
Choose Text Entry tab,
Copy/paste your code to the Text Box, and
Choose Submit Assignment to complete the Text Entry submission.
Now, to submit your code as a File Upload, follow the steps below:Choose the Re-submit Assignment button (top right),
Make sure File Upload tab is selected this time,
Choose Browse to locate your .cpp file to upload, and
Choose Submit Assignment to complete program/script file upload.
———————————————————–
Third Program:
Write a program that reads 10 integer and displays them in the reverse of the order in which they were read.
You can use a file to have 10 numbers

Posted in C++

Notes about the encryption algorithmsFor the XOR cipher, for each character in t

Notes about the encryption algorithmsFor the XOR cipher, for each character in t

Notes about the encryption algorithmsFor the XOR cipher, for each character in the unencrypted message, you should perform an exclusive or with a character in the key. For character i in the original string, the character to perform the exclusive or with is key[i % length_of_key]. Note that decrypting the XOR cipher uses the exact same steps as encrypting it!
For the Caesar cipher, for each letter in the unencrypted message, you should change its ascii value something different. Here’s a hint:
char base = isupper(text[i]) ? ‘A’ : ‘a’;
text[i] = (text[i] – base + key) % 26 + baseAnd if text[i] is less than base, add 26 to it to make sure it’s alphabetic. (Numbers won’t be encrypted.)
Notes about the programYour program should accept three command line arguments.
The name of a file to be encrypted
An int key to be used by the Caesar cipher
A single-word string to be used by the XOR cipher
If there are not three command line arguments, your program should display this error message and exit:
Usage: lab06 filename caesar_key xor_keyIf the file to be encrypted doesn’t exist, your program should display this error message and exit:
The file to be encrypted doesn’t exist.If the caesar_key argument isn’t an int, your program should display this error message and exit:
The caesar_key must be an int.If all of the command line arguments are correct, your program should work in this way:
Open the file whose name was supplied on the command line and read the contents into a string.
Encrypt that string using an XOR cipher with the xor_key.
Write the encrypted string out to a file whose name is that of the unencrypted file with _XOR appended to it.
Display a message to the terminal that you successfully wrote the encrypted file. You can see the correct format below.
Decrypt the string so you get back the original one.
Encrypt the string using a Caesar cipher with the caesar_key.
Write the encrypted string out to a file whose name is that of the unencrypted file with _CAESAR appended to it.
Display a message to the terminal that you successfully wrote the encrypted file. You can see the correct format below.
Your program must compile with no errors or warnings, and must pass all style checks in order to be submitted. In additional, it must pass all of the tests in CODE so I suggest that you focus on writing a program that does that before actually digging into the encryption.
To check if your program is working correctly, if you download the file hobbit.txt Download hobbit.txtand run your program with these command line arguments
hobbit.txt 23 bilbothen the two encrypted files from your program should be identical to these:
hobbit.txt_XOR_correct
hobbit.txt_CAESAR_correct
You can use the diff command to see if your output agrees. And the output of your program should be:
Successfully wrote hobbit.txt_XOR.
Successfully wrote hobbit.txt_CAESAR.

Posted in C++

ObjectiveThe objective of this homework assignment is to develop a C++ program t

ObjectiveThe objective of this homework assignment is to develop a C++ program t

ObjectiveThe objective of this homework assignment is to develop a C++ program to:
Gain familiarity with the /proc filesystem
Hone your problem-solving and general C++ coding skills
Project overview: ps functionBackground Here is an example of what a directory listing of /proc looks like:
amf@cse381:~$ ls /proc
1 157 191 227 28 3169 48 71 917 kmsg
10 1585 1915 229 280 3176 49 72 92 kpagecgroup
100 16 194 23 282 32 5 73 93 kpagecount
1000 1608 195 230 29 320 50 74 94 kpageflags
1007 161 196 231 290 321 5096 75 95 loadavg
101 1612 197 232 291 3246 51 76 954 locks
102 1613 198 234 2924 3277 5100 77 959 mdstat
103 1618 1989 235 2928 3283 5110 79 96 meminfo
104 1620 199 236 293 3288 5112 8 97 misc
1048 1621 1993 237 2932 3290 52 80 98 modules
105 1622 1997 239 2937 33 522 81 99 mounts
106 1635 2 240 2945 3376 523 82 acpi mpt
107 1646 20 241 3 3399 524 83 asound mtrr
1077 1651 200 242 30 34 53 84 bootconfig net
108 1655 201 244 3052 3433 55 85 buddyinfo pagetypeinfo
109 1659 202 245 3053 3475 56 86 bus partitions
1092 1668 203 246 3069 35 57 864 cgroups pressure
11 1675 204 247 3070 3508 59 865 cmdline schedstat
111 1697 205 248 3072 3559 6 868 consoles scsi
113 17 206 249 3074 362 600 869 cpuinfo self
114 1704 207 25 3075 38 61 87 crypto slabinfo
1141 1707 208 250 3077 388 62 871 devices softirqs
115 172 209 251 3078 39 63 873 diskstats stat
116 1747 21 252 3080 4 64 874 dma swaps
12 1767 210 253 3083 40 65 88 driver sys
121 1778 211 254 3088 409 655 880 dynamic_debug sysrq-trigger
122 1782 212 255 3095 41 66 881 execdomains sysvipc
123 1829 213 256 31 415 661 884 fb thread-self
13 1831 214 257 3106 43 665 89 filesystems timer_list
130 1841 215 258 3113 44 67 892 fs tty
132 1862 216 259 3114 4428 679 894 interrupts uptime
133 1869 217 26 3116 4446 68 896 iomem version
1337 1873 218 260 3129 4446 686 898 ioports version_signature
1369 1878 219 261 3145 45 69 90 irq vmallocinfo
137 1887 22 262 3157 4583 691 902 kallsyms vmstat
14 1888 224 263 3158 46 693 905 kcore zoneinfo
15 19 225 27 3163 4643 70 907 keys
1527 1903 226 279 3165 47 700 91 key-users
The files with names that are numbers are directories with information about the process with that pid. Here is a sample directory listing of one of these:
amf@cse381:~$ ls /proc/4446
arch_status fd net setgroups
attr fdinfo ns smaps
autogroup gid_map numa_maps smaps_rollup
auxv io oom_adj stack
cgroup ksm_merging_pages oom_score stat
clear_refs ksm_stat oom_score_adj statm
cmdline limits pagemap status
comm loginuid patch_state syscall
coredump_filter map_files personality task
cpu_resctrl_groups maps projid_map timens_offsets
cpuset mem root timers
cwd mountinfo sched timerslack_ns
environ mounts schedstat uid_map
exe mountstats sessionid wchanA few of these files are important to this assignment.
The fd directory shows where the output of standard input (0), standard output (1) and standard error (2) comes from or goes to. bash also has a file descriptor called 255 which it uses for some internal bookkeeping.
amf@cse381:~$ ls -l /proc/4446/fd
total 0
lrwx—— 1 amf amf 64 Nov 16 10:59 0 -> /dev/pts/0
lrwx—— 1 amf amf 64 Nov 16 10:59 1 -> /dev/pts/0
lrwx—— 1 amf amf 64 Nov 16 10:59 2 -> /dev/pts/0
lrwx—— 1 amf amf 64 Nov 16 10:59 255 -> /dev/pts/0
Using the ls -lL command on one of these files shows that it is associated with a terminal:
amf@cse381:~$ ls -lL /proc/4446/fd/1
crw–w—- 1 amf tty 136, 0 Nov 16 11:34 /proc/4446/fd/1
If the process is not associated with a terminal, the output looks like this:
amf@cse381:/proc$ ls -l /proc/1747/fd
total 0
lrwx—— 1 amf amf 64 Nov 16 10:59 0 -> /dev/null
lrwx—— 1 amf amf 64 Nov 16 10:59 1 -> /dev/null
lrwx—— 1 amf amf 64 Nov 16 10:59 2 -> /dev/null
lr-x—— 1 amf amf 64 Nov 16 10:59 3 -> /dev/random
lr-x—— 1 amf amf 64 Nov 16 10:59 4 -> /dev/urandom
l-wx—— 1 amf amf 64 Nov 16 10:59 5 -> /home/amf/.gdfuse/default/gdfuse.log
lrwx—— 1 amf amf 64 Nov 16 10:59 6 -> /dev/fuse
Using the ls -lL command on one of these files shows that it is NOT associated with a terminal:
cse381:/proc$ ls -lL /proc/1747/fd/1
crw-rw-rw- 1 root root 1, 3 Nov 16 10:58 /proc/1747/fd/1
The checkPTS function provided as starter code uses this approach to determine whether a process is associated with a terminal or not.
The loginuid file contains the uid of the user who owns the process.
amf@cse381:/proc$ cat /proc/4446/loginuid
1000The stat file contains more than 50 statistics about the process. Most of these statistics are described in the man page for procLinks to an external site.. This is a sample of what that file looks like:
amf@cse381:/proc$ cat /proc/4446/stat
4446 (bash) S 4428 4446 4446 34816 24809 4194304 4288 197003 3 28 1 8 78 71 20 0 1 0 4659
11534336 1344 18446744073709551615 94444280786944 94444281700109 140731233213088 0 0 0 65536
3686404 1266761467 1 0 0 17 5 0 0 0 0 0 94444281944752 94444281992784 94444303265792
140731233217271 140731233217276 140731233217276 140731233218542 0
The starter code for this assignment includes a definition of a structure with these fields (procStat) and a function that populates the structure by parsing a stat file (parseStatFile).
Homework requirementsYour program must operate in the following manner:
If no command line argument is provided to the program, it should display the pid, CPU time used (user + system), and the command name for all processes owned by the user that are associated with a terminal. (See the Output Samples section below for a template of how this should look.) This is accomplished by first identifying all files in the /proc directory (using the provided getProcFiles function) and reading information from the /proc/[pid]/stat file (using the provided parseStatFile function). To determine if a process belongs to a terminal, a checkPTS function is provided. The way this function is implemented guarantees that the process is owned by the user running the program. Unless you are doing a lot on your VM, you will likely have less than 10 of your processes associated with a terminal.
If the command line argument u is provided, the program should display the pid, CPU time used (user + system), and the command name for all processes owned by the user, whether they are associated with a terminal or not. In this case you do not want to run the checkPTS function on the pid, but rather check if the owner of the process matches the uid of the user running the program. The getuid()Links to an external site. syscall will be helpful for doing this. You should find somewhere around 50 – 100 processes associated with your uid when you run the program with this option.
If the command line argument a is provided, the program should display the pid, CPU time used (user + system), and the command name for all processes running on the computer, regardless of the owner. There will likely be more than 200 processes running on the system.
To get credit for this assignment, you MUST use the files in /proc to get the information needed for this assignment. Do NOT run the ps command via a system or exec call to get the information.You can certainly use ps from the command line to check whether your program is giving reasonable output. See the Output Samples section below for examples of commands to use for this purpose.
I am giving you a lot of the hard or tedious code for this assignment. Your main challenge will be to set up the logic for deciding whether to display information about a process or not.
To meet the coding style guidelines, you will need to write several helper functions. I did it with only three of them (beyond the ones I’ve provided to you), but you may need more depending on how you set up your program logic.
Make sure that your output looks like the samples below. In particular, there should be a header to the output and the time should be formatted as hh:mm:ss. For simplicity, you can assume that no running process has used more than 99:59:59 of CPU.
I am providing you with the following starter code:Please take some time to study the code in this file as there are some interesting functions provided. And this may give you hints on how to implement other helper functions.
A file homework04-starter.cppthat contains an empty main function as well as the include files that you’ll likely need.
A file homework04Helpers.h that contains the implementation of a structure and several helper functions. DO NOT MODIFY THIS FILE! When you submit your program to CODE, it will use this version of homework04Helpers.h.
Output Samples: Note that your exact output will be different. These give examples of how the different command line arguments should affect the outputNo command line arguments:
Display information about all of the user’s processes associated with a terminal.
$ ./Homework04
PID TIME CMD
3509 00:00:02 (bash)
4880 00:00:00 (bash)
5790 00:00:00 (bash)
13439 00:00:00 (bash)
13585 00:00:01 (emacs)
13604 00:00:05 (emacs)
17112 00:00:00 (Homework04)You can check whether the complete set of processes is being displayed by running the following command:
ps a | grep pts | grep -v grep | grep -v psThe pids displayed by your program should match the output of that command, plus there will be one for the Homework04 executable. The output of the ps command will be in a slightly different format than what comes from your program — verifying the set of PIDs is the important thing here.
Command line argument: u
Display information about all of the user’s processes whether they’re associated with a terminal or not.. The output should be in the same format as above, but there should be many more processes displayed (possibly close to 100).
$ ./Homework04 uYou can check whether the complete set of processes is being displayed by running the following command, replacing cse381 with the userid you use to log into your virtual machine:
ps -u cse381 | grep -v ps | grep -v grepThere may be a small discrepancy in the number of processes from the program and the output of this command, but as long as the difference is only a few processes you should be fine.
Command line argument: a
Display information about all processes. The output should be in the same format as above, but there should be many, many more processes displayed (likely more than 200).
$ ./Homework04 aYou can check whether the complete set of processes is being displayed by running the following command:
ps -efThere may be a small discrepancy in the number of processes from the program and the output of this command, but as long as the difference is only a few processes you should be fine.
Grading(5 points) Required for submission: Program must compile with no errors or warning messages and must have no style errors when submitted via the CODE plugin
(10 points) Program works correctly with no command line argument (i.e., it displays the user’s processes associated with a pts)
(5 points) Program works correctly with the command line argument u (i.e., it displays all of the user’s processes)
(5 points) Program works correctly with the command line argument a (i.e., it displays all processes)
(5 points) Documentation and programming style
Notes/TipsDevelop and test this code on your VM!
First write comments to make a plan. Include code snippets in your comments. Then start implementing. Work one feature at a time and submit it. Refactor your program as needed.This assignment is tailored to the incremental development approach I discussed in class as you get additional points when you add new features.
Because the output of this program depends on what’s running on the machine at any particular time, the CODE plugin CANNOT tell you if your output is correct. You will have to compare your output to the samples above and the output of the different ps commands.
Remember that you can use the CODE plugin multiple times to make sure your submission is valid. You can also completely submit code that partially works and do subsequent submissions as you implement more functionality. This guarantees that there’s always a gradable submission in Canvas.
DO NOT use global variables!
DO NOT modify the homework04Helper.h file! The version I am distributing will be used by the CODE plugin to compile your program.

Posted in C++

InstructionsStart with the Exercise 13 starter code on GitHubLinks to an externa

InstructionsStart with the Exercise 13 starter code on GitHubLinks to an externa

InstructionsStart with the Exercise 13 starter code on GitHubLinks to an external site..
Run the starter code in VS to verify it runs correctly.
Write a custom comparison function to be called by std::sort().
Call std::sort() to sort the elements of vector vfun in *descending* order of stars.
Write a range-based for loop to display elements of vector vfun.
Make your output readable and understandable by a user, similar to the sample output below. use substr() to display strings of stars instead of number ratings.
Rubric
Exercise 13 Rubric
Exercise 13 Rubric
CriteriaRatingsPts
This criterion is linked to a Learning OutcomeRuns correctly according to the assignment instructions.Submitted code shows that you carefully followed the assignment instructions. All required features are present and each feature works correctly.
5 to >4.0 ptsGood job!
4 to >0 ptsNot yet…
5 pts
This criterion is linked to a Learning OutcomeFollows class coding standardUses appropriate and descriptive variable names and proper indentation. Has file comment header and all functions have comment headers. Function prototypes are before main() and preceded by a comment header. Function definitions are after main().
4 to >3.0 ptsGood job!
3 to >0 ptsNot yet…
4 pts
This criterion is linked to a Learning OutcomeSubmitted code compiles with no errors and no warnings and runs without crashing.
4 ptsGood job!
0 ptsNot yet…
4 pts
This criterion is linked to a Learning OutcomeGood UXUser prompts are informative and presented neatly. Output is neatly formatted and easy to read. User interface follows a consistent scheme for a good User eXperience.
2 to >1.5 ptsGood job!
1.5 to >0 ptsNot yet…
2 pts
Total Points: 15

Posted in C++

The In class chapter 10 pdf file is the work you have to do and the chapter9 and

The In class chapter 10 pdf file is the work you have to do and the chapter9 and

The In class chapter 10 pdf file is the work you have to do and the chapter9 and 10 pdf is for your reference. Please use the information from Chapter9 and 10 pdf only for your reference. No external source is permitted. Please do it and send me.

Posted in C++

Investigate the concept of coding practices in general and specifically those in

Investigate the concept of coding practices in general and specifically those in

Investigate the concept of coding practices in general and specifically those in C++. Find at least three well-documented vulnerabilities. Discuss the problem that these vulnerabilities present, how they are exploited, and what can be done to prevent them.

Posted in C++

Welcome to the world of game development!After a long journey to find ‘optimum’,

Welcome to the world of game development!After a long journey to find ‘optimum’,

Welcome to the world of game development!After a long journey to find ‘optimum’, ‘free’ resources for Unreal Engine 5, I decided that we will instead use a much lighter-weight alternative. Sorry to those who already installed it–play with it and learn to make games visually with Blueprints… 🙂
We’re going to try out raylib, which is an open source, relatively lightweight game engine.
Watch and follow along with the videos below–that is, reproduce everything as shown in the videos.
How to install raylib with C++ on Windows and use it with Visual Studio Code (<5mins)https://www.youtube.com/watch?v=PaAcVk5jUd8Links to an external site. Pong Game with C++ and Raylib - Beginner Tutorial (~45mins)https://www.youtube.com/watch?v=VLJlTaFvHo4Links to an external site. Note that you will likely need to pause and re-watch multiple parts of the videos in order to ensure you're doing everything correctly Your submission will consist of FIVE (5) screenshots (all pasted into a single Word doc): Screenshot with your desktop running VS Code (or Visual Studio) Screenshot showing a folder with the raylib template files (as demonstrated in the video) At least three (3) screenshots of the pong game in development--your choice which steps to choose BONUS (50pts): running, completely functional pong game--including something on the screen that identifies you so I know it's not from someone else Resources: VS Code and Visual Studio Community: https://visualstudio.microsoft.com/free-developer-offers/Links to an external site. raylib video game library: https://www.raylib.com/Links to an external site. Source code for pong game from video: https://github.com/educ8s/Cpp-Pong-Game-RaylibLinks to an external site.

Posted in C++