Friday, August 30, 2019

Junior Programmming ONLY

In-Class Activity: Simple Calculator






Instructions:  Create a Simple Calculator program in C++.  The calculator should have the ability to add, subtract, divide, or multiply two inputted values.  Use a menu-style format to allow the user to select the type of operation they would like to do.  The program only needs to run once.

Do necessary research to allow adequate time for you to complete the program within the next class period.  To be collected and graded on Day 1 Cycle 2

Junior 1 Homework

Class:  Information Technology
Date Administered: August 30, 2019
Date Due:  Next IT Class
Submission Format:  Hardcopy (printed)
To be graded.  10 points each

Instructions:  Write structured algorithms for the following problems:  (simple algorithms)

1.  The cost to go to Altun Ha are as follows:  $5.00 for Belizean and $10.00 for non-Belizeans.  Write an algorithm that calculates and shows the total for a group going to Altun Ha.

2. Write an algorithm that asks the user to enter the diameter of a circle.  The algorithm should calculate and show the circumference of a circle using the formula circumference = 2 Pi R

3. Write an algorithm that prompts the user to enter the name and age of three friends.  The algorithm should find and show the average age of the friends.

4.  Write an algorithm that asks the user to enter a number and store in X.  The algorithm should find and show the square and cube of the number.

Algo WHAT???

Algorithms... series of instructions that rigorously defines the solution to a problem.

Types of Algorithms:

  1. Simple
  2. Conditional 
  3. Loops
  4. Arrays
Formats in which algorithms are represented?
  • Narrative ~ written in plain English text.  Example:  Instructions on a recipe card.
  • Pseudocode ~ English-like text and code.  Example:  Read num (input a number)
  • Structured ~ Codes.  The only format that is executable.
  • Flowchart ~ graphical (or pictorial) representation of an algorithm.
When writing algorithms, there are some words that have special meanings.  These are known as reserved words.  Listed below are a few of the reserved words used in algorithms.
Print - display on screen.  Used in output statements
Input - enter via keyboard.  Used in input statements
Input key - press any key to continue.  Used to terminate an algorithm; called the terminator
name - a reserved word; cannot be used as a variable name
width - a reserved word; cannot be used as a variable name
add - a reserved word; cannot be used as a variable name
date - a reserved word; cannot be used as a variable name

Algorithms fall under the first phase in computer program development (Problem Solving Phase)
Steps in the problem solving phase:
  1. Define the problem
  2. Find a solution
  3. Evaluate alternate solutions
  4. Choose the most efficient solution and write an algorihtm
  5. Test the algorithm for correctness
TO define the problem, programmers use a tool called a Defining Diagram which is a three column table that separates a problem into input, processing, and output.  This is commonly referred to as an IPO table.  (Input/Processing/Output)  

Example:

I
P
O
Num1
Num2
1.      Read Num1, Num2
2.      Calculate Sum
3.      Print Sum
Sum
This is the defining diagram to deconstruct a problem that asks to calculate and output the sum of two numbers.

In the Input (I) section, anything that the user has to enter goes here
In the Processing (P) section, anything that the computer has to do goes here
In the Output (O) section, the solution values that will be displayed goes here

You try one: Prepare an IPO table to solve the problem:
A technician makes $90.00 per day and 1.5 times that value for overtime hours.  Write an algorithm that prompts the user to enter the amount of days and overtime hours worked by the technician, and calculate the week salary for the technician.  Your algorithm should display the total week salary with suitable labels.

After you've completed the IPO table, give it a try to write the algorithm.  It's a simple algorithm.  Submit your solution via email for bonus points on your lowest quiz grade.  Value - 2 bonus points