Introduction to Computers and Applications
CS 110 Introduction to Computers and Applications
Developing Solutions to Problems
Programming is defined as a creative process involving:
Designing a solution to a problem.
Developing a sequence of instructions that a computer will follow to accomplish a task.
Concepts and Terms
Algorithm: An ordered sequence of steps designed to solve a problem.
IPO (Input-Process-Output): A fundamental design framework for understanding how a computer program operates.
Input: Data that must be entered before a computer can process it.
Process: Operations or calculations performed on the input data.
Output: The display of results after processing is complete.
Storage: Locations where data is held for future use, including the identification of variables.
Pseudo-code: A textual representation of algorithm instructions, showcasing the steps taken to solve the problem.
Flowchart: A diagrammatic representation of an algorithm or process, visually illustrating the sequence of steps.
Python Program: A set of Python statements executed in a sequence to perform the intended task.
Example Scenarios
Example #1: Sprite Movement and Calculation
Scenario: A user places a sprite on a stage and the sprite announces its position.
Flowchart Representation:
Program Code:
```python
x = int(input("Enter int value for X: "))
y = int(input("Enter int value for Y: " ))
sum = x + y
print ("sum is: ", sum)
- **Pseudo-code**:
1. Get x
2. Get y
3. Add x and y and store the result in sum
4. Display sum
- **IPO Analysis**:
- **Input**: Two integers, x and y.
- **Processing**: Calculate the sum of x and y using the formula:
- **Output**: Display the sum.
- **Storage**: Variables x, y, and sum.
### Example #2: Final Price Calculation with Sales Tax
- **Scenario**: Calculate the final price of an item including sales tax. The sprite announces the final price.
- **Flowchart Representation**:
- **Program Code**:
python
itemPrice = float(input("Enter item price: "))
taxRate = float(input("Enter tax rate: "))
tax = taxRate * itemPrice
finalPrice = itemPrice + tax
print ("Final Price is: ", finalPrice)
```
IPO Analysis:
Input: Two values, the item price and the tax rate.
Processing:
Calculate the tax using the formula:
Calculate the final price using the formula:
Output: The final price of the item.
Storage: Variables itemPrice, taxRate, and finalPrice.