PIC10A Lecture 1


Section 1.1

Computer and Computer programs

Elements of Hardware


Software Development


Question: Calculate the increase percentage of the tuition fee.

Problem specification

Design and Implementation

Pseudocode for the example

  1. Input this year's tuition fee
  2. Input last year's tuition fee
  3. calculate the increase precentage by the formula
  4.   increasePercentage = (last year's tuition fee - this year's tuition fee)/(last year's tuition fee)  times 100%
  5. output the result
Here is the code

using namespace std;

int main() {
    double thisYearFee, lastYearFee, percentage;
    cout << "Please enter last year's tuition fee: ";
    cin >> lastYearFee;
    cout << "Please enter this year's tuition fee: ";
    cin >> thisYearFee;

    percentage = (thisYearFee - lastYearFee)/lastYearFee;

    cout << "The tuition increases " << percentage*100 << "%.\n";

    return 0;

Here is the output of the program
Please enter last year's tuition fee: 1233      
Please enter this year's tuition fee: 1459
The tuition increases 18.3293%.

Building(Compiling and linking)

Testing/Debugging, Maintenance, and Documentation

Compiler and Syntax Error

Explanation of the program

#include<iostream>     /_____________ these two lines are included
using namespace std;   \               so that the libaries about input/output
                                       are available to the program
int main() {
               <----------------- fill your codes here

    return 0;

double thisYearFee, lastYearFee, percentage; declare 3 decimal numbers
cout << "Please enter last year's tuition fee: "; cout <<"blah blah blah";  
outputs blah blah blah on the screen
cin >> lastYearFee; cin >> x;  asks the user to input a value.
The value will be stored in a variable named x.