Pseudo Code Generator

Computer Component Quotation and Calculation System

This pseudocode outlines the logic for a computer component quotation tool, covering VAT calculations, customer input validation, item selection processing, and total cost display, ensuring accurate pricing for user-selected computer


Empty image or helper icon

Prompt

Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click

        ' Constants
        Const VAT_RATE As Decimal = 0.15
        Dim Markup As Decimal

        ' Variables
        Dim customerName As String
        Dim customerSurname As String
        Dim total As Decimal
        Dim VAT As Decimal = 0.15
        Dim totalPayable As Decimal
        Dim decMousePrice As Decimal
        Dim decMonitorPrice As Decimal
        Dim decGraphicsCardPrice As Decimal
        Dim decKeyboardPrice As Decimal
        Dim decProcessorPrice As Decimal
        Dim decComputerPrice As Decimal
        Dim decTotalCost As Decimal
        Dim decGrandTotal As Decimal


        ' Event handler for Calculate button
        If chkComputer.Checked = True Then
            decComputerPrice = 799
        End If
        If chkGraphicsCard.Checked = True Then
            decGraphicsCardPrice = 224
        End If
        If chkKeyboard.Checked = True Then
            decKeyboardPrice = 362.18
        End If
        If chkMonitor.Checked = True Then
            decMonitorPrice = 399
        End If
        If chkMouse.Checked = True Then
            decMousePrice += 249
        End If
        decTotalCost = (Markup + 40 / 100 * (totalPayable)) + VAT * (decComputerPrice)



        ' Validate customer input
        If txtName.Text = "" Or txtSurname.Text = "" Then
            MessageBox.Show("Please enter customer name and surname.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End If

        ' Capture customer details
        customerName = txtName.Text
        customerSurname = txtSurname.Text

        ' Reset total for each calculation
        total = 0

        ' Calculate component and peripheral costs with markup
        If chkComputer.Checked Then total += CalculateCost(799) ' Example cost
        If chkGraphicsCard.Checked Then total += CalculateCost(224) ' Example cost
        If chkMonitor.Checked Then total += CalculateCost(399) ' Example cost
        If chkKeyboard.Checked Then total += CalculateCost(362.18) ' Example cost
        If chkMouse.Checked Then total += CalculateCost(249) ' Example cost

        ' Calculate additional RAM and HDD costs
        If cmbDDR3.SelectedIndex > 0 Then total += CalculateCost(256 * cmbDDR3.SelectedIndex) ' Example cost per module
        If cmbHDD.SelectedIndex > 0 Then total += CalculateCost(199 * cmbHDD.SelectedIndex) ' Example cost per HDD

        ' Calculate VAT and total payable
        VAT = total * VAT_RATE
        totalPayable = total + VAT

        ' Display results
        lstDisplay.Items.Clear()
        lstDisplay.Items.Add("Quotation for: " & customerName & " " & customerSurname)

        ' Display selected components and their prices

        If chkComputer.Checked Then

                lstDisplay.Items.Add("Computer: " & "R" & CalculateCost(1895.59))
                lstDisplay.Items.Add(vbTab & "MotherBoard: " & "AMD Socket ")
                lstDisplay.Items.Add(vbTab & "CPU: " & "Intel core i3-6100")
                lstDisplay.Items.Add(vbTab & "RAM: " & "DDR3")
                lstDisplay.Items.Add(vbTab & "HDD: " & "GD hard drive sata 2.5")
                lstDisplay.Items.Add("")
            End If

        If chkGraphicsCard.Checked Then lstDisplay.Items.Add("Graphics Card: " & "R" & CalculateCost(799))
        If chkMonitor.Checked Then lstDisplay.Items.Add("Monitor: " & "R" & CalculateCost(700))
        If chkKeyboard.Checked Then lstDisplay.Items.Add("Keyboard: " & "R" & CalculateCost(180))
        If chkMouse.Checked Then lstDisplay.Items.Add("Mouse: " & "R" & CalculateCost(38))

        ' Display additional RAM and HDD details
        If cmbDDR3.SelectedIndex > 0 Then
            lstDisplay.Items.Add("Additional RAM: " & cmbDDR3.SelectedIndex.ToString() & "x R" & CalculateCost(289))
        End If
        If cmbHDD.SelectedIndex > 0 Then
            lstDisplay.Items.Add("Additional HDD: " & cmbHDD.SelectedIndex.ToString() & "x R" & CalculateCost(539))
        End If

        ' Add spacing before totals
        lstDisplay.Items.Add("")

        ' Display totals at the bottom
        lstDisplay.Items.Add("Total: " & total.ToString("C"))
        lstDisplay.Items.Add("VAT: " & VAT.ToString("C"))
        lstDisplay.Items.Add("Total Payable: " & totalPayable.ToString("C"))
    End Sub

    ' Function to calculate cost with markup
    Private Function CalculateCost(cost As Decimal) As Decimal
        Return cost + (cost * 0.4)
    End Function

    ' Event handler for Clear button
    Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
        txtName.Clear()
        txtSurname.Clear()
        chkComputer.Checked = False
        chkGraphicsCard.Checked = False
        chkMonitor.Checked = False
        chkKeyboard.Checked = False
        chkMouse.Checked = False
        cmbDDR3.SelectedIndex = 0
        cmbHDD.SelectedIndex = 0
        lstDisplay.Items.Clear()

    End Sub

    ' Event handler for Exit button
    Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
        Dim dlgResults As Double
        dlgResults = MessageBox.Show("ARE YOU SURE YOU WANT TO EXIT ?", "Exit CONFIRMATIONi", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
        If dlgResults = vbYes Then
            Me.Close()
        End If
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click

    End Sub

Answer

Pseudo Code for Component Quotation and Calculation

Constants and Variables

  1. Define constants for VAT:

    • Set VAT_RATE = 0.15
  2. Declare variables:

    • customerName as String
    • customerSurname as String
    • total as Decimal
    • VAT as Decimal
    • totalPayable as Decimal
    • decMousePrice, decMonitorPrice, decGraphicsCardPrice, decKeyboardPrice, decProcessorPrice, decComputerPrice as Decimal
    • decTotalCost, decGrandTotal as Decimal

Main Event Handler: btnCalculate_Click

  1. Event handler for the Calculate button:

    • Check if the component checkboxes are selected, assign prices accordingly:
      • If chkComputer is checked, set decComputerPrice = 799
      • If chkGraphicsCard is checked, set decGraphicsCardPrice = 224
      • If chkKeyboard is checked, set decKeyboardPrice = 362.18
      • If chkMonitor is checked, set decMonitorPrice = 399
      • If chkMouse is checked, increment decMousePrice by 249
  2. Calculate total and VAT:

    • Compute decTotalCost as:
      • decTotalCost = (Markup + 40 / 100 * (totalPayable)) + VAT * (decComputerPrice)
  3. Validate customer input:

    • If txtName or txtSurname is empty:
      • Show error message: "Please enter customer name and surname."
      • Exit the subroutine
  4. Capture customer details:

    • Assign txtName to customerName
    • Assign txtSurname to customerSurname
  5. Reset total:

    • Set total = 0
  6. Calculate selected component costs:

    • If chkComputer is checked, add the cost of computer
    • If chkGraphicsCard is checked, add the cost of graphics card
    • If chkMonitor is checked, add the cost of monitor
    • If chkKeyboard is checked, add the cost of keyboard
    • If chkMouse is checked, add the cost of mouse
  7. Calculate additional costs:

    • If cmbDDR3 has a selected value greater than 0, add cost for additional RAM modules:
      • total += CalculateCost(256 * cmbDDR3.SelectedIndex)
    • If cmbHDD has a selected value greater than 0, add cost for additional HDDs:
      • total += CalculateCost(199 * cmbHDD.SelectedIndex)
  8. Calculate VAT and total payable:

    • VAT = total * VAT_RATE
    • totalPayable = total + VAT
  9. Display results:

    • Clear the display list lstDisplay
    • Add quotation header with customer name and surname
    • For each selected component, add item to lstDisplay, including their priced calculated via CalculateCost.
  10. Add spacing before displaying totals:

    • Add a blank line to lstDisplay
    • Display total, VAT and total payable formatted as currency

Function: CalculateCost

Function CalculateCost(cost As Decimal) As Decimal
    Return cost + (cost * 0.4)  // Add 40% markup
End Function

Other Event Handlers

btnClear_Click

  1. Handler to clear input fields and selections:
    • Clear txtName and txtSurname
    • Uncheck all component checkboxes
    • Reset dropdowns cmbDDR3 and cmbHDD to their default states
    • Clear the list lstDisplay

btnExit_Click

  1. Handler for exit confirmation:
    • Show confirmation dialog for exiting the application
    • If the user clicks Yes:
      • Close the application

Form1_Load

  1. Handler for form load event:
    • (Currently unimplemented)

PictureBox1_Click

  1. Handler for PictureBox click event:
    • (Currently unimplemented)

Summary

This pseudocode serves as a concise representation of the business logic associated with the quotation and calculation functionality for a computer system purchase. It encompasses constant declarations, input validation, item selection processing, total calculations with VAT, and user interface interaction. This structure is designed to facilitate understanding and communication in the early stages of software development while ensuring accuracy in computation and display of pricing details.

Create your Thread using our flexible tools, share it with friends and colleagues.

Your current query will become the main foundation for the thread, which you can expand with other tools presented on our platform. We will help you choose tools so that your thread is structured and logically built.

Description

This pseudocode outlines the logic for a computer component quotation tool, covering VAT calculations, customer input validation, item selection processing, and total cost display, ensuring accurate pricing for user-selected computer components.