Fundamentals of Programming Practical Assessment Guide

Institutional and Assessment Overview

  • Institution: The Rift Valley National Polytechnic.

  • Department: Information and Communication Technology (ICT).

  • Course Codes: L6CS-25M, L6CS-25S.

  • Assessment Title: Understand Fundamentals of Programming – Practical Assessment.

  • Academic Year: ) 2026.

  • Instructions to Candidates:

    • Candidates must attempt all tasks provided in the paper.

    • The assessment must be completed within the stipulated time.

    • The paper consists of two distinct practical tasks.

    • Practical 1: This task is to be completed on paper.

    • Practical 2: This task requires the use of a JAVA compiler.

    • Saving Convention: The Java program must be saved as Main.java.

Problem Scenario: Retail Shop Program

  • Location: A small retail shop situated at Kabasis Centre.

  • Objective: To develop a simple program that assists the shopkeeper in calculating the total amount a customer should pay when purchasing a specific type of item.

  • Operational Flow:

    1. The program prompts the user to input the name of the item (e.g., Milk).

    2. The program prompts the user to input the unit price of the item in Kenya Shillings (e.g., 100.00100.00).

    3. The program prompts the user to input the quantity or number of items being purchased (e.g., 33).

    4. The program performs the required calculation.

    5. The program displays the item name and the resulting total cost back to the user.

Technical Logic and Formulas

  • Required Inputs:

    1. Item Name (String\text{String})

    2. Unit Price (Float/Double\text{Float/Double})

    3. Quantity (Integer\text{Integer})

  • Mathematical Formula for Total Cost:

    • total cost=unit price×quantity\text{total cost} = \text{unit price} \times \text{quantity}

  • Currency Representation: Kenya Shillings (Ksh).

Practical 1: Program Design Requirements

  • Allocation: 20 Marks20\text{ Marks}.

  • Task: Design a solution for the shopkeeper's scenario showing the logic from start to finish.

  • Allowed Methodologies (Choose one):

    1. Flowchart: A graphical representation of the program's logic.

    2. Algorithm: A step-by-step descriptive process.

    3. Pseudocode: Structural code-like representation.

  • Mandatory Design Elements:

    • Explicit representation of the "Start" of the program.

    • Clear indication of the three inputs: item name, unit price, and quantity.

    • A dedicated step for the calculation of the total cost.

    • A step for the display of results to the user.

    • Explicit representation of the "End" of the program.

Practical 2: Java Implementation Requirements

  • Allocation: 30 Marks30\text{ Marks}.

  • Task: Translate the design from Practical 1 into a functional Java program.

  • Structural Constraints:

    • The code must be contained within a class named Main.

    • The program must feature a correctly implemented public static void main(String[] args) method.

    • Input handling must utilize the Scanner class from the java.util package.

  • Functional Requirements:

    • Implement logic to read item name, unit price, and quantity from the user.

    • Perform the calculation according to the provided formula.

    • Display the output including the item name and formatted total cost.

    • The code must compile successfully and execute without runtime errors.

Expected Sample Output and Behavior

  • Execution Example:

    • User prompt: Enter item name:

    • User input: Milk

    • User prompt: Enter unit price:

    • User input: 70.00

    • User prompt: Enter quantity:

    • User input: 2

    • Resulting Display: Item: Milk

    • Resulting Display: Total Cost: Ksh 140.00

  • Calculation Trace:

    • unit price=70.00\text{unit price} = 70.00

    • quantity=2\text{quantity} = 2

    • Total Cost=70.00×2=140.00\text{Total Cost} = 70.00 \times 2 = 140.00