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
Prompt
Answer
Pseudo Code for Component Quotation and Calculation
Constants and Variables
Define constants for VAT:
- Set VAT_RATE = 0.15
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
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
- Check if the component checkboxes are selected, assign prices accordingly:
Calculate total and VAT:
- Compute decTotalCost as:
- decTotalCost = (Markup + 40 / 100 * (totalPayable)) + VAT * (decComputerPrice)
- Compute decTotalCost as:
Validate customer input:
- If txtName or txtSurname is empty:
- Show error message: "Please enter customer name and surname."
- Exit the subroutine
- If txtName or txtSurname is empty:
Capture customer details:
- Assign txtName to customerName
- Assign txtSurname to customerSurname
Reset total:
- Set total = 0
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
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)
- If cmbDDR3 has a selected value greater than 0, add cost for additional RAM modules:
Calculate VAT and total payable:
- VAT = total * VAT_RATE
- totalPayable = total + VAT
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.
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
- 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
- Handler for exit confirmation:
- Show confirmation dialog for exiting the application
- If the user clicks Yes:
- Close the application
Form1_Load
- Handler for form load event:
- (Currently unimplemented)
PictureBox1_Click
- 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.
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.