CS1101 (SOPH-0062) Introduction to Java Programming - 1

pdf

School

Western Governors University *

*We aren’t endorsed by this school

Course

1101

Subject

Computer Science

Date

Jan 9, 2024

Type

pdf

Pages

1

Uploaded by GeneralThunderPony43

Report
CS1101 (SOPH-0062) Introduction to Java Programming - 1.1- Learning to Code – Forming an Algorithm Flash Cards Question Answer 1. What is an algorithm in the context of programming? An algorithm is a logical step-by-step plan used to solve a problem. 2. Why is it important to consider different ways to solve a problem before designing an algorithm? Considering different ways to solve a problem helps determine the best way to solve it and optimize the solution, especially for programs that run frequently. 3. What are the basic criteria to consider when preparing to write an algorithm? The basic criteria include determining the inputs and outputs, the order of steps, types of decisions within the program, and any repeatable parts of the problem. 4. What is the purpose of using comments in Java code? Comments in Java code are used to explain how the program or a piece of code works and are ignored by the compiler. They help make the code easier to understand for others reading it. 5. In the Computer Guessing Game example, what is the purpose of the randomNumber variable? The randomNumber variable stores a randomly generated integer between 1 and 100, which the user tries to guess. 6. What does the guessCount variable represent in the guessing game? The guessCount variable tracks the number of guesses the user needed to guess the number correctly. 7. How does the Computer Guessing Game algorithm ensure that the number is guessed in 7 guesses or less? The algorithm consistently halves the range of possible numbers by guessing the midpoint, which systematically reduces the search space until the number is found. 8. Why is it important to choose the middle number as the first guess in the Computer Guessing Game? Choosing the middle number as the first guess eliminates 50% of the possibilities, making the process of finding the correct number more efficient. 9. What happens if the guess is too high or too low in the Computer Guessing Game? If the guess is too high, the upper limit is adjusted to the guess; if the guess is too low, the lower limit is adjusted to the guess. This narrows down the range for the next guess. 10. What is the significance of the logical steps behind the algorithm in programming? The logical steps behind the algorithm are crucial because they form the foundation of the solution to the problem, independent of the underlying code.
Discover more documents: Sign up today!
Unlock a world of knowledge! Explore tailored content for a richer learning experience. Here's what you'll get:
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help