Free Essay

Computer Science Major

In:

Submitted By romo
Words 732
Pages 3
Programs Ch. 8
2. Lottery Number Generator
This program generates a 7-digit lottery number. It should have an Integer array with 7 elements. It has a loop that steps through the array, randomly generating a number between 0 and 9 for each element. Another Loop displays the contents of the array. * Generate seven numbers * Output seven numbers Input | Processing | Output | | Generate seven lottery numbers | Display all seven lottery numbers |

Main Module () Declare integer lotteryNumber [SIZE] Declare integer SIZE = 7 Declare integer index Declare Integer num Call Get_lot_Number (lotteryNumber, SIZE)
Call showWin
End Module

//This module will make the generate the lottery numbers
Get_lot_Number (Integer ref lotteryNumber [], Integer SIZE)
Declare integer index = 0 For index = To SIZE -1 Set lotteryNumber [index] = random (0, 9) Display values [index] End For
End Module
//This module will show the winning numbers
Module showWin (Integer ref lotteryNumber [], Integer SIZE)
Declare Integer count = 0
For count = 0 to SIZE-1
Display lotteryNumber [count]
End For
End Module

Flowchart

10. Tic-Tac-Toe Game
Main Module () //generate board
//Declaring constants Constant String tileB = ” _ ”
Constant String tileX = ” X ”
Constant String tileO = ” O ”
Constant Integer WIN = 3
Constant Integer idxMAX = 2
Constant Integer tileMAX = 9
Constant String LBR = “\n”
//Other declarations
Declare Boolean Integer DRAWN = 0 // 0 is false, 1 is true
Declare Boolean Integer isOver = 0 // 0 is false, 1 is true
Declare String cturn = tileX
Declare Integer SIZE = 3
Declare String board = [ [], [], [] ]
Declare Integer row = 0
Declare Integer col = 0
For row = 0 To SIZE -1
For col = 0 To SIZE -1
Set board[row][col] = tileB
End For
End For
Call showBoard(board)
//make moves
Declare Integer moveNum = 0;
Do
Set cturn = move(cturn, board)
Set moveNum = moveNum + 1
While moveNum < tileMAX AND isGameOver(board) == 0
Display “GAME OVER!”
End Main
//Display Functions
Function showMsg(msg)
Declare String Msg
Display Msg
End Function

Function shower (msg)
Declare String errorPrefix = “ERROR: ”
Display errorPrefix, msg
End Function

Function showBoard (pboard)
Declare String output = “”;
For row = 0 To SIZE -1
For col = 0 To SIZE -1
Set output = output, pboard[row][col] //draw tile
End For
// draw new row
Set output = output, LBR
End For
Display showMsg(output)
End Function

//Validation Functions
Function outOfBounds (row, column)
If row < 0 OR row > idxMAX Then
Display showErr(“Out of Bounds”)
Return 1
Else If column < 0 OR column > idxMAX Then
Display showErr(“Out of Bounds”)
Return 1
Else
Return 0
End If
End Function

Function occupied(pboard, row, column)
If pboard[row][column] != tileB Then
Display showErr(“Slot is occupied.”)
Return 1
Else
Return 0
End If
End Function

//Game Functions
Function takeTurn(pturn)
If pturn == tileX Then
Return tileO
Else
Return tileX
End If
End Function

Function move (player, pboard) //take player input
Declare Integer moveRow = 0
Declare Integer moveCol = 0
Do
Display “Please enter Row for “, player, “”
Input moveRow
Display “Please enter Column”, player, “”
Input moveCol
While outOfBounds (moveRow, moveCol) == 1 OR occupied (pboard, moveRow, moveCol) == 1
Set pboard [moveRow] [moveCol] = player
Call showBoard (pboard)
Return takeTurn (player)
End Function

//State Functions
//Check game state
Function isGameOver (pboard)
Declare Integer rc = 0
Declare Integer i = 0, j = 0
//checkRow
For i = 0 To SIZE -1
If pboard[i][0] == tileX AND pboard[i][1] == tileX AND pboard[i][2] == tileX Then
Display “X wins”
Set rc = 1
Else If pboard [i] [0] == tileO AND pboard[i][1] == tileO AND pboard[i][2] == tileO Then
Display “O wins”
Set rc = 1
End If
End For
//check column
For j = 0 To SIZE -1
If pboard [0][j] == tileX AND pboard[1][j] == tileX AND pboard[2][j] == tileX Then
Display “X wins”
Set rc = 1
Else If pboard [0][j] == tileO AND pboard[1][j] == tileO AND pboard[2][j] == tileO Then
Display “O wins”
Set rc = 1
End If
End For
//check across
If pboard [1][1] == tileX Then
If pboard [0][0] == tileX AND pboard[2][2] == tileX Then
Display “X wins”
Set rc = 1
Else If pboard [0][2] == tileX AND pboard[2][0]==tileX
Display “X wins”
Set rc = 1
End If
Else If pboard[1][1] == tileO Then
If pboard [0][0] == tileO AND pboard[2][2] == tileO Then
Display “O wins”
Set rc = 1
Else If pboard [0][2] == tileO AND pboard[2][0]==tileO
Display “O wins”
Set rc = 1
End If
End If
Return rc
End Function

Similar Documents

Free Essay

Career as Computer Scientist

...Environmental Education Standout Annotated Bibliography Abrea, Alma. “Computer Scientist Job Description, Education Requirements and Career Outlook.” USnewsuniversitydirectory.com U.S News University Directory. 2012 web. 24 Mar. 2016 Alma considers a master degree is required or PhD in Computer Science is required for the job. She also says that it takes four years for a bachelor’s degree and five years for a PhD. She also argues that “most occupations in the field require a graduate degree.” Abrea writes for usnewsdirectory.com which is a university directory web site. Abrea doesn’t have a bias. This editorial contradicts come of my other sources, which claim that a college degree is needed for computer science. Hoffman, Micheal. “A Guide to Computer Science Careers.” Computerscienceonline.org Computer Science Online. 2016 web. 24 Mar. 2016 Hoffman is a graduate of the University of California at Santa Barbara and the Santa Barbara College of Law, Hoffman began his professional career as an attorney in Los Angeles. After a brief period in the Hollywood film production business, Huffman now works as a freelance writer while he pursues his dream of becoming a published fiction author and screenwriter. Hoffman considers that a software developers get paid more than a User Interface Design. He argues that “User Interface Design annually makes $61,000 per year according to payscale.com and a Software Developer makes slightly over $100,000 in May 2013.” Huffman bias is that...

Words: 3203 - Pages: 13

Premium Essay

Interview With Dr Azalov Interview Paper

...State faculty member, I chose to meet with Dr. Pavel Azalov. My intended major is computer science, so Dr. Azalov seemed to be the best option for myself. When I was coming up with questions to ask during the interview, I wanted to focus on my future at Penn State and what I should expect when it comes time for me to take courses related to computer science. By doing this, I hoped to gain a better understanding of the process of getting a degree in computer science. My first question I asked was to see if I was personally ready to begin taking college level computer science courses. I was not sure of the level of experience with computer programming was recommended for entry level classes in the field of study. As I would come to learn, there is no experience required for basic programming classes, and this came to me as sort of a surprise. Almost every major subject, whether it is math, writing, history, or science, usually requires some sort of background knowledge of the subject. Some people may not think of it that way, though. These...

Words: 519 - Pages: 3

Premium Essay

The Fluidity of Computer Science

...The Fluidity of Computer Science. Gender Norms & Racial Bias in the Study of the Modern "Computer Science" Computer science or computing science designates the scientific and mathematical approach in computing. A computer scientist is a scientist who specialises in the theory of computation and the design of computers. Its subfields can be divided into practical techniques for its implementation and application in computer systems and purely theoretical areas. Some, such as computational complexity theory, which studies fundamental properties of computational problems, are highly abstract, while others, such as computer graphics, emphasize real-world applications. Still others focus on the challenges in implementing computations. For example, programming language theory studies approaches to description of computations, while the study of computer programming itself investigates various aspects of the use of programming languages and complex systems, and human-computer interaction focuses on the challenges in making computers and computations useful, usable, and universally accessible to humans. Computer science deals with the theoretical foundations of information, computation, and with practical techniques for their implementation and application. History The earliest foundations of what would become computer science predate the invention of the modern digital computer. Machines for calculating fixed numerical tasks such as the abacus have existed since antiquity...

Words: 2298 - Pages: 10

Premium Essay

Protecting the Virtual Environment

...Environment After months of searching for a major, I finally discovered computer science. I had, at one point or another, intended to major in film, English education, physics, anthropology and nearly every other major offered. Following my father’s advice, I took a class in computer science and I instantly changed my major. According to the Department of Computer Science at Boston University, computer science is “the systematic study of the feasibility, structure, expression, and mechanization of the methodical processes (or algorithms) that underlie the acquisition, representation, processing, storage, communication of, and access to information, whether such information is encoded in bits and bytes in a computer memory or transcribed in genes and protein structures in a human cell.” Job growth significantly contributed to my decision on a major. According to the U.S. Bureau of Labor Statistics, careers requiring at least a B.S. in Computer Science are seeing the greatest amount of growth, and are expected to continue to do so through 2016. Also, people in this major tend to receive the greatest average starting salary at $65,000. However, the field is not without its problems. Because computing is so new and many laws have yet to form, the computer science environment faces ethical issues such as intellectual ownership, security, and what can be published to the Internet. Currently, the field of computer science is facing one of the greatest issues of the technological...

Words: 1011 - Pages: 5

Premium Essay

What Sparked Your Interest In Computer Science

...1) What sparked your interest in computer science? How did this lead you to major in computer science and what do you hope to accomplish with your degree? In your answer, please describe how your experiences have influenced the goals you have for yourself. My interest in computer science started when I was a young child. I’ve always been interested in using the computer, and I’ve been fortunate enough to be born at the precipice of the technological age. This has allowed me to grow up alongside technology, getting bigger while technology helped the world get smaller. I am completely comfortable with technology and have an aptitude for figuring my way around any piece of technology. Using the computer feels natural to me; it feels like where I should be centering my hard work, ambition, and focus. When deciding a major for college, I...

Words: 1836 - Pages: 8

Premium Essay

System Administrator

...Career Choice: Network and Computer Systems Administrator Business and Writing for the IT Professional July 26, 2009 Abstract A network and systems administrator is responsible for network security, installing new applications, implementing software updates, monitoring the integrity of the system, developing management programs, and performing routine backups. As has been noted throughout my research, there has been a decline in technology majors throughout the past couple of years, thus affecting the job market. The survey that was conducted on high school seniors, as well as research done by some universities, has proven that lack of information and interest affects this type of career choice. By properly informing potential technology students and offering them resources, we can better equip our future system and network administrators to perform to their potential. Topic Proposal Author Background An interest in computers came to my attention shortly after graduating from high school. I first involved myself in working with cameras and fixing them for several customers. The satisfying knowledge that I gained came from realizing that I could take apart, fix a piece of technology and do it well. Computers as a hobby came only after my brother gave me one to fix and keep for my use. Although I was daunted at first, I took apart and drew diagrams, to remember where the components where located. I had no previous experience from computers that I had learned at my...

Words: 1945 - Pages: 8

Premium Essay

Why Is Computer Science Important In Canada

...Clearly Scholarship Award If Computer Science was no longer taught in colleges or universities, Canada would look much different than today. It would be hard to imagine what Canada would look like if Computer Science did not exist considering everything today is done on computers and there needs to be someone to figure how to make it all work. No one gives much thought to the individuals who spent countless days and weeks tediously programming away and creating these complex computational systems that we rely on a day to day basis and must also work a hundred percent of the time without errors. Computational systems such as the traffic lights on the road or health and medical systems in a hospital are now in some way controlled by computers and software. Canada would like a country that would struggle to keep up with other technology driven countries such as China, United States of America, France etc....

Words: 520 - Pages: 3

Premium Essay

Pert

...Computer science From Wikipedia, the free encyclopedia Jump to: navigation, search Computer science or computing science (abbreviated CS) is the study of the theoretical foundations of information and computation and of practical techniques for their implementation and application in computer systems.[1][2] Computer scientists invent algorithmic processes that create, describe, and transform information and formulate suitable abstractions to model complex systems. Computer science has many sub-fields; some, such as computational complexity theory, study the fundamental properties of computational problems, while others, such as computer graphics, emphasize the computation of specific results. Still others focus on the challenges in implementing computations. For example, programming language theory studies approaches to describe computations, while computer programming applies specific programming languages to solve specific computational problems, and human-computer interaction focuses on the challenges in making computers and computations useful, usable, and universally accessible to humans. The general public sometimes confuses computer science with careers that deal with computers (such as information technology), or think that it relates to their own experience of computers, which typically involves activities such as gaming, web-browsing, and word-processing. However, the focus of computer science is more on understanding the properties of the programs used to implement...

Words: 5655 - Pages: 23

Premium Essay

An Evolution of Computer Science Research

...Abbreviated version of this report is published as "Trends in Computer Science Research" Apirak Hoonlor, Boleslaw K. Szymanski and M. Zaki, Communications of the ACM, 56(10), Oct. 2013, pp.74-83 An Evolution of Computer Science Research∗ Apirak Hoonlor, Boleslaw K. Szymanski, Mohammed J. Zaki, and James Thompson Abstract Over the past two decades, Computer Science (CS) has continued to grow as a research field. There are several studies that examine trends and emerging topics in CS research or the impact of papers on the field. In contrast, in this article, we take a closer look at the entire CS research in the past two decades by analyzing the data on publications in the ACM Digital Library and IEEE Xplore, and the grants awarded by the National Science Foundation (NSF). We identify trends, bursty topics, and interesting inter-relationships between NSF awards and CS publications, finding, for example, that if an uncommonly high frequency of a specific topic is observed in publications, the funding for this topic is usually increased. We also analyze CS researchers and communities, finding that only a small fraction of authors attribute their work to the same research area for a long period of time, reflecting for instance the emphasis on novelty (use of new keywords) and typical academic research teams (with core faculty and more rapid turnover of students and postdocs). Finally, our work highlights the dynamic research landscape in CS, with its focus constantly ...

Words: 15250 - Pages: 61

Premium Essay

Why One Hour a Week of Programming Isn't Enough...

...the idea that all students should spend one hour a week learning about computer science is laudable, it's an effort that will only lead to further segregation between everyday life and the 'sciences'. Instead of teaching computer programming as a stand-apart subject, it needs to be included in every subject and taught as part of the normal curriculum. Why? Well, if you look at the use of computers in any walk of life, it's never a completely separte phenomenon. In fact, the idea that it IS separate has lead to the current problem where most computer programmers are severely lacking in social skills and grammar skills. This is because as computer technology progressed it was subjugated into a niche called 'nerds'. The idea of 'nerds' helped shaped a group of computer programmers who avidly railed against soft sciences and other topics that didn't fall into the hard technology realm. As a side note - one of the main problems with our current education system is the fact that it's not just computer programming we're breaking out - we still teach classes that are ONLY based in chemistry, physics, biology. Yet, in today's world, it's impossible to understand biology or physics without chemistry knowledge. The sciences are all intertwined - ergo, the rise of biochemistry, biophysical chemistry and other such subsets. Using our antiquated educational system a student isn't able to actually major in biophysics or other specifics until they reach a graduate degree in...

Words: 742 - Pages: 3

Premium Essay

My Major Goals

...Majoring in computer wasn't always what I strived for but fo y future wise it's more of a realistic goal in life. This semester I would love to see how computer sciences goes for me. I Joseph Martinez have set goals during this semester that aline it self to my major. Passing all my classes is my number one priority in this semester I can’t if i'm failing my classes, failing out in my classes would mean not getting my degree for computer science. My goal, to be a successful person once i'm done with college. I’m aiming pretty high for my education. I also want a master degree and i'm willing to try hard for it. I have minors goals and skills to require my success in school. Studying , Focusing on school mainly in my life. Right now school is what’s important and only focus I need. Being well organized is another key for success. I shall never be absent less it's a dire situation, nor should I be tardy i'll try to refrain from being tardy....

Words: 535 - Pages: 3

Premium Essay

A Survey of Career Opportunities in Computer and Information Sciences

...A Survey of Career Opportunities in Computer and Information Sciences Kazim ATASOY SUNY Fredonia Computer Science Author Note This paper was prepared for CSIT 490: Seminar on Selected Topics, Section 01, and Taught by Professor Zubairi. Abstract Computer and information science jobs are becoming to worlds’ biggest job opportunities. Most of the companies already integrated their system with technology and there are still some country side companies that haven’t integrated with technology but day by day this companies will be integrated too. Because, technology is more than being just a machine, it is being our life. Therefore, somebody should invent, produce and adapt our desires to this technology. In this research paper, I am going to find answers to some questions about career opportunities in computer and information sciences that creates all of this technologies. Question List 1. What are the major activities assigned to people employed in the CIS field? 2. What technical skills are necessary in order to be successful in CIS? 3. What educational preparation is required? 4. What kinds of organizations hire people in this occupation? 5. What kind of work would an entry-level bachelor's degree person would likely do? 6. What are the opportunities for advancement? What positions might someone hold as he or she advances? Give a sequence of positions starting from entry level position and also show expected salary in each position. 7. Are the opportunities...

Words: 4626 - Pages: 19

Free Essay

Paul Erdos

...people, one would designate that the person actually consulted with Erdos to write a paper, and two would be assigned to someone who consulted with a Erdos number one person etc. In his true and pure dedication to the love of his life, mathematics, Erdos would travel university-to-university and door-to-door of other high-minded mathematicians and would want to learn from them or teach them constantly saying, “ my mind is open for thought.” Through his life, he made many extreme advances in mathematics and actually contributed to the learning and elements of Computer Science. These advances include those of combinatorics, his multiple mathematical theories and the graph theory. One major contribution that Erdos gave to the computer science community was the idea and expansion of combinatorics which deals with the manipulation and probability of sets of numbers which can obviously be used in the idea of arrays in Computer Science such as Java and C#. This is the question of how many possibilities of numbers can be in a set and be arranged in a set and also how to make the set more favorable through manipulation such as...

Words: 1726 - Pages: 7

Premium Essay

My Interest In Mathematics

...challenging problems in science and engineering or related fields by using numerical computation have reached to a new level. Computation is today considered as a very important tool needed for the advancement of scientific knowledge and engineering practice along with theory and experiment. In the modern world all sorts of calculations are done by sophisticated computer systems. Every company and research farms from small-scale to large-scale are getting more and more reliant on mathematical principles these days. Numerical simulation has enabled the study of complex systems and natural phenomena that would be too expensive or sometimes impossible, to study directly by experimentation. As a matter of fact, engineers and scientists now require solid knowledge of computer science and applied mathematics in order to get optimized output from a system. To make things easier in this matter, Scientific Computing is a discipline that conglomerates Mathematics, Computer Science and Engineering in a single degree program and utilizes mathematical models in computer simulations to solve complex problems for not only in science laboratories but also in business and engineering firms. I have always been fascinated by the application of mathematics and computer science in the real world problems. That is why...

Words: 842 - Pages: 4

Free Essay

Statement of Purpose

...out and the instantaneous information of the outcome that encourages one for further study of a justification in question, is what I find most appealing about computer science. Since my childhood, I have an ardor towards problem solving, cracking puzzles and brain gam es. Later on that transformed to zeal towards Computer programming. This motivates me to learn more in the field of computers. My choice to pursue graduate study in the United States is emphasized by my aspiration to excel in my field of interest. My fascination for science and technology and extreme interest in the ever-growing world of technology stimulated me to take up engineering. I opted for major in Electronics and Communication engineering with a passionate urge to research into the challenging field .All through the course of my undergraduate study ,I was exposed to diverse courses with applications like C Programming and data structures,Control systems, Operating systems, Computer networks, Computer organization, Digital Signal Processing and Architecture, Pulse and Digital circuits, Micro processors and Micro controllers, Digital Communications, Integrated Circuit Applications enhanced my subject knowledge and I secured first-class results in my engineering. I was well versed in Programming languages like C and Data Structures, Java. The Computer networking course has fascinated me in particular. I have done comprehensive reading and attained good knowledge of OSI and TCP/IP reference models, The Transportation...

Words: 1337 - Pages: 6