CS201 First Homework Lol

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

CS 201 Homework 00

CHANGEME: 00
Stefano Fochesatto

September 1, 2019

Source Code Link: https://github.com/StefanoFochesatto/cs201/


tree/master/hw0

1 Design
The first program is a very simple ”Hello World” program with
a little bit of a twist. First it simply prints out a string that says
”Hello World”, then we were asked to print ”Hello World” 10 times
to demonstrate loops. So to do so I demonstrated printing out
multiple strings using a for loop, while loop, do while loop, and a
nested four loop. The next program prints out the epic Beowulf
from from a .txt file, doing so line by line to retain formatting.
The Last program prints out a description of the game Nim, I
started writing the game but it’s not done yet.

2 Post Mortem
With the Poem program I could only open the .txt file using an
explicit directory, even with the Beowulf.txt file in the project
directory the command ”Infile.open(”Beowulf.txt”);” never man-
aged to open the file. With the Hello World program I kept trying
to initialize integers inside the condition statement of the while
and do while loops but you can really only do that in for loops.

1
3 Answers to Questions
• What are some uses on software in science, medicine, or en-
tertainment?

Tools like scientific instruments and medical equipment can


only operate with proper software. Software like Matlab,
RStudio and Autodesk are used by scientists and engineers
around the world. As far as entertainment goes there are a
myriad of programs focused specifically to create content.
Programs like the Adobe Suite, and Logic Pro X are all aimed
towards making it easier for artists and creators to create
content.

• What does a software developer look like?

A software developer looks like, a person who is a creative


problem solver. A software developer is also an excellent
communicator and excels at working in a team.

• How much memory does your computer have? Main mem-


ory? Disk?

My laptop has 4 Gigabytes of 1600 Megahertz DDR3 RAM,


and a 128 Gigabyte Solid State Drive.

• Identify at least five kinds of applications for computer pro-


grams and pick the one that you find the most interesting
and that you would like to participate in someday. Write a
short paragraph on why you chose the one you did.

2
Web Development, Game Design, Computer Modeling, Statis-
tics, and Artificial Intelligence are all applications for com-
puter programming. As a Mathematics major with a fo-
cus in discrete and combinatorial mathematics, I find Com-
puter Modeling the most interesting. Visual representations
of discrete counting methods, shortest-path algorithms and
graph theory are fascinating too me and they can only fea-
sible be made with a strong background in computer pro-
gramming.

4 Sample Output

Listing 1: Hello World Program Output


Hello , World !( Using Single String )
Hello , World !( Using For Loop )
Hello , World !( Using For Loop )
Hello , World !( Using For Loop )
Hello , World !( Using For Loop )
Hello , World !( Using For Loop )
Hello , World !( Using For Loop )
Hello , World !( Using For Loop )
Hello , World !( Using For Loop )
Hello , World !( Using For Loop )
Hello , World !( Using For Loop )
Hello , World !( Using While Loop )
Hello , World !( Using While Loop )
Hello , World !( Using While Loop )
Hello , World !( Using While Loop )
Hello , World !( Using While Loop )
Hello , World !( Using While Loop )
Hello , World !( Using While Loop )
Hello , World !( Using While Loop )
Hello , World !( Using While Loop )
Hello , World !( Using While Loop )
Hello , World !( Using Do While Loop )
Hello , World !( Using Do While Loop )

3
Hello , World !( Using Do While Loop )
Hello , World !( Using Do While Loop )
Hello , World !( Using Do While Loop )
Hello , World !( Using Do While Loop )
Hello , World !( Using Do While Loop )
Hello , World !( Using Do While Loop )
Hello , World !( Using Do While Loop )
Hello , World !( Using Do While Loop )
Hello , World !( Using Nested For Loop )
Hello , World !( Using Nested For Loop )
Hello , World !( Using Nested For Loop )
Hello , World !( Using Nested For Loop )
Hello , World !( Using Nested For Loop )
Hello , World !( Using Nested For Loop )
Hello , World !( Using Nested For Loop )
Hello , World !( Using Nested For Loop )
Hello , World !( Using Nested For Loop )
Hello , World !( Using Nested For Loop )
Program ended with exit code : 0

5 Hello World
1 #include <iostream>
2
3 int main(int argc, const char * argv[]) {
4 std::cout << "Hello, World!(Using Single String)\n";
5 for (int i=1; i<=10;i++)
6 {
7 std::cout << "Hello, World!(Using For Loop)\n";
8 }
9 int j=1;
10 while (j<=10){
11 std::cout <<"Hello, World!(Using While Loop)\n";
12 j++;
13 }
14 int k=1;
15 do {
16 std::cout <<"Hello, World!(Using Do While Loop)\n";
17 k++;
18 }
19 while(k<=10);
20 for (int x=1; x<=2;x++)
21 {

4
22 for (int y=1; y<=5;y++)
23 {
24 std::cout << "Hello, World!(Using Nested For Loop)\n";
25 }
26
27 }
28 }

6 Poem
1 #include <iostream>
2 #include <fstream>
3
4 using namespace std;
5 int main(int argc, const char * argv[]) {
6
7 ifstream Infile;
8 Infile.open("/Users/stefanofochesatto/Documents/Documents/cs201/hw0/Poem/Poem Fe
9
10 if (!Infile) {
11 cout << "Unable to open file";
12 exit(1); // terminate with error
13 }
14
15 string x;
16 while (getline(Infile,x)) {
17 cout << x << endl ;
18 }
19 Infile.close();
20 }

7 Game
1 #include <iostream>
2 using namespace std;
3 int main(int argc, const char * argv[]) {
4
5
6
7 cout <<"Nim is a mathematical game of strategy in which two players take turns r
8 cout << "objects from distinct heaps or piles. On each turn, a player must remov
9 cout << "object, and may remove any number of objects provided they all come fro
10 cout << "Depending on the version being played, the goal of the game is either t
11 cout << "object, or to take the last object.";

5
12 return 0;
13 }

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy