Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

THE UNIVERSITY OF LAHORE

Case Studies
In OOP and VB
by

Salman Zafar MCC01113022

Presented to: Sir Nadeem

Case Study: Checking Account Balance Problem


CHECKING ACCOUNT BALANCE PROGRAM
#include <iostream> #include <iomanip> #include <conio.h> using namespace std; class CheckBalance { private: float start_balance; // input: balance at start of period float current_balance; // output: balance at end of period int num_checks; // output: number of checks for period int num_deps; // output: number of deposits for period public: CheckBalance(); void instruct_user(); // PROVIDE USER INSTRUCTIONS void initiate(); // INITIATE PROCESSING int process_transactions();// PROCESS ALL TRANSACTIONS void print_report(); // PRINT REPORT }; CheckBalance::CheckBalance() { start_balance = 0.0; current_balance = 0.0; num_checks = 0; num_deps = 0; } // PROVIDE USER INSTRUCTIONS void CheckBalance::instruct_user() { // Prints user instructions. cout << "This is your Checkbook Balancing Program. It will" << endl; cout << "keep a record of all checks written and deposits " << "made." << endl; cout << "Please enter all information as prescribed." << endl << endl; } // INITIATE PROCESSING void CheckBalance::initiate() // OUT: account balance at the start of the month { char response; // user's response to input question do { cout << "Enter checkbook balance at start of current " << "period: $ "; cin >> start_balance; cout << "Is this starting balance of $ " << start_balance << " correct?" << endl; cout << "(Enter Y or N) => "; cin >> response; } while ( response != 'Y' && response != 'y'); cout <<"Thank you! Now we can begin processing your" << "transactions." << endl << endl; return; // end initiate

// PRINT REPORT void CheckBalance::print_report()

{ cout << endl; cout << "Balance at start of period: $ " << start_balance << endl; cout << "Balance at end of period: $ " << current_balance << endl << endl; cout << "Number of deposits for this period: " << num_deps << endl; cout << "Number of checks for this period: " << num_checks << endl << endl; cout << "End of report." << endl; } // end print_report int CheckBalance::process_transactions() { int num, dep, wthdrwl; cout << "Function process_transactions entered." << endl; current_balance = start_balance; num_checks = 0; num_deps = 0; do { cout<<"Enter your number"<<endl; cout<<"1 : Deposit"<<endl<<"2 : withdrawal"<<endl<<"3 : Report"<<endl; cin>>num; switch(num) { case 1: cout<<"Enter the money you want to cin>>dep; current_balance += dep; num_deps += 1; cout<<"Your transaction has break; case 2: cout<<"Enter the money you want to cin>>wthdrwl; current_balance -= wthdrwl; num_checks += 1; cout<<"Your transaction has break; case 3: print_report(); break;

deposit : $ ";

been processed"<<endl;

withdrawal : $ ";

been processed"<<endl;

default: cout<<"invalid input"<<endl<<"Program exiting.."; } } while (num == 1 || num == 2); return 0; } // end process_transactions int main () { int dep; CheckBalance ch1; cout << setiosflags (ios::fixed | ios::showpoint) << setprecision (2); ch1.instruct_user(); ch1.initiate (); ch1.process_transactions(); _getch(); return 0; }

Checking Account Balance Program Output

Case Study: Computing Insurance Dividends


FINDS AND PRINTS THE INSURANCE DIVIDEND #include <iostream> #include <conio.h> #include <iomanip> using namespace std; class CompDiv { private: static const float basic_rate; static const float bonus_rate; float premium; int number_claims; float dividend; public: void instruct_user(); float compute_dividend(); void set(float,int); int get_numberClaims(); }; const float CompDiv::basic_rate= 0.045; const float CompDiv::bonus_rate=0.005; // needed for cin and cout // needed for setprecision

// basic dividend rate 4.5% // bonus dividend rate 0.5% // input: premium amount // input: number of claims // output: dividend amount

int main () { CompDiv d1; float prmum; int numbrClms; float dvdnd; // Display user instructions. d1.instruct_user(); // Enter premium and number of claims. cout << "Premium amount: $"; cin >> prmum; cout << "Number of claims: "; cin >> numbrClms; d1.set(prmum,numbrClms); // Compute the dividend. dvdnd = d1.compute_dividend (); // Print total dividend. cout << "Total dividend is $" << setprecision (2) << setiosflags(ios::showpoint | ios:: fixed) << dvdnd << endl; if (d1.get_numberClaims() == 0) cout << "This includes a bonus dividend for zero claims!" << endl; getch(); return 0; }

// Displays user instructions. void CompDiv::instruct_user() { cout << "This program displays an insurance policy dividend." << endl; cout << "The basic dividend is " << basic_rate; cout << " times the premium." << endl; cout << "A bonus dividend of " << bonus_rate; cout << " times the premium is paid" << endl; cout << "for policies with no claims against them." << endl << endl; return; } // end instruct_user

// COMPUTE DIVIDEND USING BONUS RATE WHEN EARNED. float CompDiv::compute_dividend() { dividend = premium * basic_rate; // basic dividend if (number_claims == 0) dividend = dividend + premium * bonus_rate; // plus bonus return dividend; } // end compute_dividend void CompDiv::set(float p, int nc) { premium = p; number_claims = nc; } int CompDiv::get_numberClaims() { return number_claims; }

Insurance Dividends Program Output

Case Study: Payroll Problem


Computes and displays gross pay and net pay given an hourly rate and number of hours worked. Deducts union dues of $15 if gross salary exceeds $100; otherwise, deducts no dues. Also Compute overtime pay
#include <iostream> #include<conio.h> using namespace std; const const const const float float float float MAX_NO_DUES = 100.00; // dues = 15.00; // MAX_NO_OVERTIME = 40.0;// OVERTIME_RATE = 1.5; // max earnings before dues (dollars) dues amount (dollars) max hours before overtime overtime rate

class Payroll { private: float float float float public: void set(float,float); //set values for hours and rate void instructUser(); float computeGross(); float computeNet(); }; int main () { float hrs,rt,grss,nt; Payroll p1; // Display user instructions. p1.instructUser(); // Enter hours and rate. cout << "Hours worked: "; cin >> hrs; cout << "Hourly rate: "; cin >> rt; p1.set(hrs,rt); // Compute gross salary. grss = p1.computeGross(); // Compute net salary. nt = p1.computeNet(); // Print gross and net. cout << "Gross salary is " << grss << endl; cout << "Net salary is " << nt << endl; _getch(); return 0; } // Insert lower-level functions here. hours; rate; gross; net; // // // // input: hours worked input: hourly pay rate (dollars) output: gross pay (dollars) output: net pay (dollars)

// ... // Displays user instructions void Payroll::instructUser() { cout << "This program computes gross and net salary." << endl; cout << "A dues amount of " << dues << " is deducted for" << endl; cout << "an employee who earns more than " << MAX_NO_DUES << endl << endl; cout << "Overtime is paid at the rate of " << OVERTIME_RATE << endl; cout << "times the regular rate for hours worked over " << MAX_NO_OVERTIME << endl << endl; cout << "Enter hours worked and hourly rate" << endl; cout << "on separate lines after the prompts." << endl; cout << "Press <return> after typing each number." << endl << endl; } // end instructUser void Payroll::set(float h, float r) { hours = h; rate = r; } // FIND THE GROSS PAY float Payroll::computeGross() { float regularPay; // pay for first 40 hours float overtimePay; // pay for hours in excess of 40 // Compute gross pay. if (hours > MAX_NO_OVERTIME) { regularPay = MAX_NO_OVERTIME * rate; overtimePay = (hours - MAX_NO_OVERTIME) * OVERTIME_RATE * rate; gross = regularPay + overtimePay; } else gross = hours * rate; return gross; // end computeGross

// Find the net pay float Payroll::computeNet() { if (gross > MAX_NO_DUES) net = gross - dues; // deduct dues amount else net = gross; // no deductions return net; // end computeNet

Payroll Program Output

Case Study: AREA AND CIRCUMFERENCE OF A CIRCLE


// FINDS AND PRINTS THE AREA AND CIRCUMFERENCE OF A CIRCLE #include <iostream> #include <conio.h> using namespace std; class Circle { private: static const float pi; float radius; // input: radius of circle float area; // output: area of circle float circum; // output: circumference of circle public: Circle(); void set_radius(float r); float get_radius(); void Compute_Area(); void Compute_circumference(); void Display(); }; const float Circle::pi=3.14159; Circle::Circle() { radius = 0.0; area = 0.0; circum = 0.0; } int main () { float r; Circle c1; // object of type Circle cout << "Enter the circle radius: "; // Read radius of circle cin >> r; c1.set_radius(r);

c1.Compute_Area(); c1.Compute_circumference(); c1.Display(); cout<< endl; getch(); return 0;

// Compute area of circle. // Compute circumference of circle. // Display area and circumference.

} void Circle::set_radius(float r) { radius = r; } float Circle::get_radius() { return radius; } void Circle::Compute_Area() { area = pi * radius * radius; } void Circle::Compute_circumference() { circum = 2 * pi * radius; } void Circle::Display() { cout << "The area of the circle is " << area << endl; cout << "The circumference of the circle is " << circum ; }

AREA AND CIRCUMFERENCE OF A CIRCLE Program Output

Case Study: Coin Collection


// DETERMINES THE VALUE OF A COIN COLLECTION #include <iostream> #include <conio.h> using namespace std; class Coins { private: int pennies; // input: count of pennies int nickels; // input: count of nickels int dollars; // output: value of coins in dollars int change; // output: value of coins in cents int total_cents; // total cents represented public: void Read_Pennies_Nickles_From_User(); void Comppute_Cents_Dollars_Change(); void Display(); };

int main () { Coins c; c.Read_Pennies_Nickles_From_User(); c.Comppute_Cents_Dollars_Change(); c.Display(); getch(); return 0; }

// Read in the count of nickels and pennies. // Find total cents and value of dollars and change.

void Coins::Read_Pennies_Nickles_From_User() { cout << "Enter the number of nickels and press return: "; cin >> nickels; cout << "Enter the number of pennies and press return: "; cin >> pennies; } void Coins::Comppute_Cents_Dollars_Change() { total_cents = 5 * nickels + pennies; dollars = total_cents / 100; change = total_cents % 100; } void Coins::Display() { cout << "Your collection is worth " << dollars << " dollars and " << change << " cents." << endl; }

Coin Collection Program Output

Case Study: ALPHABETICALLY FIRST LETTER


// FINDS AND DISPLAYS THE ALPHABETICALLY FIRST LETTER #include<iostream> #include<conio.h> using namespace std; // Functions used ... class FirstLetter { private: // needed for cin and cout

char char char char public: char void };

ch1; ch2; ch3; alpha_first;

// input: three letters to be processed

// output: alphabetically first letter // return alphabetically first letter among two letters

get_first(); set(char,char,char);

int main () { char c1,c2,c3; FirstLetter fl; // Read three letters. cout << "Enter any three letters: "; cin >> c1 >> c2 >> c3; fl.set(c1,c2,c3); // Save the alphabetically first of ch1,ch2 and ch3 in alpha_first.

// Display result. cout << endl << fl.get_first() << " is the first letter alphabetically." << endl; _getch(); return 0; }

// FINDS THE ALPHABETICALLY FIRST LETTER OF PAIR char FirstLetter::get_first() { if (ch1 < ch2 && ch1 < ch3) return ch1; // letter1 comes before letter2 and letter3 else if (ch2 < ch3 && ch2 < ch1) return ch2; // letter2 comes before letter3 and letter1 else if (ch3 < ch1 && ch3 < ch2) return ch3; // letter3 comes before letter1 and letter2 }

void FirstLetter::set(char c1, char c2, char c3) { ch1 = c1; ch2 = c2; ch3 = c3; }

ALPHABETICALLY FIRST LETTER Program Output

Case Study: Payroll Problem Form Payroll Public Class frmPayroll


'variables declaration Dim hoursWorked, hourlyRate, grossSalary, netSalaty As Double ' object p1 of type clsPayroll Dim p1 As New clsPayroll Private Sub frmPayroll_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load txtbxDues.Text = "$" & p1.SetAndGet_Dues() txtbxMaxNoDues.Text = "$" & p1.SetAndGet_maxNoDues() End Sub Private Sub btnClclt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClclt.Click 'Button click event procedure If (txtbxHrsWrkd.Text.ToString = "" Or txtbxHrlyRt.Text.ToString = "") Then MsgBox("one or more field is left empty") Else ' get values from text boxes hoursWorked = txtbxHrsWrkd.Text hourlyRate = txtbxHrlyRt.Text End If 'set values to class data members p1.SetValues(hoursWorked, hourlyRate) 'compute gross salary and save in variable grossSalary = p1.ComputeGross() 'output result in text box txtbxGrssSlry.Text = "$" & grossSalary 'set values p1.SetValues(hoursWorked, hourlyRate, grossSalary) 'compute net salary and save in variable netSalaty = p1.ComputeNet() 'output result in text box txtbxNtSlry.Text = "$" & netSalaty End Sub Private Sub txtbxDues_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtbxDues.TextChanged p1.SetAndGet_Dues() = txtbxDues.Text End Sub Private Sub txtbxMaxNoDues_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtbxMaxNoDues.TextChanged p1.SetAndGet_maxNoDues() = txtbxMaxNoDues.Text End Sub

End Class

Class Payroll Public Class clsPayroll


Private maxNoDues As Double = 100.0 Private dues As Double = 25.0 Const max_hours As Double = 40.0 Const overtime_rate As Double = 2.0 Private hours, rate, gross, net As Double Public Sub SetValues(Optional ByVal h As Double Optional ByVal r As Double Optional ByVal g As Double Optional ByVal n As Double hours = h rate = r gross = g net = n End Sub Public Property SetAndGet_maxNoDues() As Double Get Return maxNoDues End Get Set(ByVal value As Double) maxNoDues = value End Set End Property Public Property SetAndGet_Dues() As Double Get Return dues End Get Set(ByVal value As Double) dues = value End Set End Property

= = = =

0.0, 0.0, 0.0, 0.0)

Public Function ComputeGross() As Double If hours <= max_hours Then Return hours * rate Else Return (max_hours * rate) + (hours - max_hours) * overtime_rate * rate End If End Function Public Function ComputeNet() As Double If (gross > maxNoDues) Then Return gross - dues Else Return gross End If End Function

End Class

Payroll Program Output

Case Study: Checking Account Balance Problem Program Output

Form Opening Balance


Public Class frmOpeningBalance
Private Sub frmOpeningBalance_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub btnOpnngBlnc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpnngBlnc.Click If txtbxOpnngBlnc.Text = "" Then frmCheckBalanceVB1.txtbxOpngBlnc.Text = "$" & 0 frmCheckBalanceVB1.txtbxEndngBlnc.Text = "$" & 0 frmCheckBalanceVB1.txtbxBlnc.Text = "$" & 0 Else frmCheckBalanceVB1.txtbxOpngBlnc.Text = "$" & txtbxOpnngBlnc.Text frmCheckBalanceVB1.txtbxEndngBlnc.Text = "$" & txtbxOpnngBlnc.Text frmCheckBalanceVB1.Current_Balance = txtbxOpnngBlnc.Text frmCheckBalanceVB1.txtbxBlnc.Text = "$" & txtbxOpnngBlnc.Text End If Me.Close() frmCheckBalanceVB1.Enabled = True frmCheckBalanceVB1.TopMost() = True frmCheckBalanceVB1.txtbxChck.Focus() End Sub Private Sub txtbxOpnngBlnc_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtbxOpnngBlnc.TextChanged End Sub

End Class

Form Add Record


Public Class frmAddRecord
Private Sub btnAddRcrd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddRcrd.Click If frmCheckBalanceVB1.i < 19 Then frmCheckBalanceVB1.i += 1 frmCheckBalanceVB1.y += 19 frmCheckBalanceVB1.tbName = "dtp" & CStr(frmCheckBalanceVB1.i) Dim dp As New DateTimePicker dp.Name = frmCheckBalanceVB1.tbName dp.Format = DateTimePickerFormat.Short frmCheckBalanceVB1.Controls.Add(dp) dp.Location = New Point(0, frmCheckBalanceVB1.y) dp.Size = New Size(87, 20) frmCheckBalanceVB1.tbName = "txtbxChck" & CStr(frmCheckBalanceVB1.i) Dim tb As New TextBox tb.Name = frmCheckBalanceVB1.tbName frmCheckBalanceVB1.Controls.Add(tb) tb.Location = New Point(93, frmCheckBalanceVB1.y) tb.Size = New Size(87, 20)

tb.BorderStyle = BorderStyle.FixedSingle frmCheckBalanceVB1.tbName = "txtbxTrnsactnDscrptn" & CStr(frmCheckBalanceVB1.i) Dim tb2 As New TextBox tb2.Name = frmCheckBalanceVB1.tbName frmCheckBalanceVB1.Controls.Add(tb2) tb2.Location = New Point(179, frmCheckBalanceVB1.y) tb2.Size = New Size(350, 20) tb2.BorderStyle = BorderStyle.FixedSingle frmCheckBalanceVB1.tbName = "txtbxCtgry" & CStr(frmCheckBalanceVB1.i) Dim tb3 As New TextBox tb3.Name = frmCheckBalanceVB1.tbName frmCheckBalanceVB1.Controls.Add(tb3) tb3.Location = New Point(528, frmCheckBalanceVB1.y) tb3.Size = New Size(143, 20) tb3.BorderStyle = BorderStyle.FixedSingle frmCheckBalanceVB1.tbName = "txtbxDbt" & CStr(frmCheckBalanceVB1.i) Dim tb4 As New TextBox tb4.Name = frmCheckBalanceVB1.tbName frmCheckBalanceVB1.Controls.Add(tb4) tb4.Location = New Point(670, frmCheckBalanceVB1.y) tb4.Size = New Size(100, 20) tb4.BorderStyle = BorderStyle.FixedSingle frmCheckBalanceVB1.tbName = "txtbxCrdt" & CStr(frmCheckBalanceVB1.i) Dim tb5 As New TextBox tb5.Name = frmCheckBalanceVB1.tbName tb5.Location = New Point(769, frmCheckBalanceVB1.y) tb5.Size = New Size(100, 20) tb5.BorderStyle = BorderStyle.FixedSingle tb5.Text = txtbxDeposit.Text tb5.TextAlign = ToolBarTextAlign.Right frmCheckBalanceVB1.Controls.Add(tb5) frmCheckBalanceVB1.tbName = "txtbxBlnc" & CStr(frmCheckBalanceVB1.i) Dim tb6 As New TextBox tb6.Name = frmCheckBalanceVB1.tbName tb6.Location = New Point(868, frmCheckBalanceVB1.y) tb6.Size = New Size(100, 20) tb6.BorderStyle = BorderStyle.FixedSingle tb6.TextAlign = ToolBarTextAlign.Right frmCheckBalanceVB1.Current_Balance += tb5.Text tb6.Text = "$" & frmCheckBalanceVB1.Current_Balance frmCheckBalanceVB1.Controls.Add(tb6) End If Me.Close() frmCheckBalanceVB1.txtbxEndngBlnc.Text = "$" & frmCheckBalanceVB1.Current_Balance End Sub Private Sub frmAddRecord_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub

End Class

Form Check Balance


Public Class frmCheckBalanceVB1
Public Public Public Public y As Short = 28 i As Short = 0 tbName As String Current_Balance As Integer = 0

Dim cb As clsCheckBalanceVB1 Private Sub checkBalanceVB1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Enabled = False frmOpeningBalance.Show() End Sub Private Sub txtbxDbt0_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtbxDbt.TextChanged txtbxCrdt.Enabled = False 'd txtbxBlnc.Text = "$" & CType(txtbxBlnc.Text, Integer) - CType(txtbxDbt.Text, Integer) If Not (txtbxCrdt.Text = "") And Not (txtbxDbt.Text = 0) Then 'd MsgBox("You can either debit or credit") txtbxDbt.Text = 0 End If If txtbxDbt.Text = 0 Then txtbxCrdt.Enabled = True 'd txtbxCrdt.Focus() 'd End If End Sub Private Sub txtbxCrdt0_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtbxCrdt.TextChanged txtbxBlnc.Text += txtbxCrdt.Text End Sub

Public Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click frmAddRecord.Show() End Sub

Private Sub btnDltRcrd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDltRcrd.Click Dim c As Control For Each c In Me.Controls If c.Name = "dtp" & CStr(i) Then Me.Controls.Remove(c) End If Next For Each c In Me.Controls If c.Name = "txtbxChck" & CStr(i) Then Me.Controls.Remove(c) End If Next For Each c In Me.Controls If c.Name = "txtbxTrnsactnDscrptn" & CStr(i) Then Me.Controls.Remove(c) End If Next For Each c In Me.Controls If c.Name = "txtbxCtgry" & CStr(i) Then Me.Controls.Remove(c)

End If Next For Each c In Me.Controls If c.Name = "txtbxDbt" & CStr(i) Then Me.Controls.Remove(c) End If Next For Each c In Me.Controls If c.Name = "txtbxCrdt" & CStr(i) Then Me.Controls.Remove(c) End If Next For Each c In Me.Controls If c.Name = "txtbxBlnc" & CStr(i) Then Me.Controls.Remove(c) End If Next If i >= 0 Then i -= 1 End If If y > 28 Then y -= 19 End If End Sub

End Class

Class Check Balance


Public Class clsCheckBalanceVB1
Private Private Private Private start_balance As Double = 0.0 ' input: balance at start of period current_balance As Double = 0.0 ' output: balance at end of period num_checks As Integer = 0 ' output: number of checks for period num_deps As Integer = 0 'output: number of deposits for period

Public Property SetAndGet_start_balance() As Double Get Return start_balance End Get Set(ByVal value As Double) start_balance = value End Set End Property

End Class

Case Study: Coin Collection Program Output

Form Coin Collection


Public Class frmCoinCollection
Dim c1 As New clsCoinCollection Dim nickles, pennies, dollar, change As Integer

Private Sub frmCoinCollection_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub txtbxNickels_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtbxNickels.TextChanged

If (txtbxNickels.Text.ToString = "") Then nickles = 0 End If If (txtbxNickels.Text.ToString <> "") Then nickles = CType(txtbxNickels.Text.ToString, Integer) End If If (txtbxPennies.Text.ToString <> "") Then pennies = CType(txtbxPennies.Text.ToString, Integer) End If c1.SetValues(pennies, nickles) If (c1.CalTotalCents() >= 100) Then dollar = c1.CalTotalCents() \ 100 txtbxDollars.Text = CType(dollar, Integer) End If txtbxCents.Text = c1.CalTotalCents Mod 100

End Sub Private Sub txtbxPennies_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtbxPennies.TextChanged If (txtbxPennies.Text.ToString = "") Then pennies = 0 End If If (txtbxPennies.Text.ToString <> "") Then pennies = CType(txtbxPennies.Text.ToString, Integer) End If If (txtbxNickels.Text.ToString <> "") Then nickles = CType(txtbxNickels.Text.ToString, Integer) End If c1.SetValues(pennies, nickles) If (c1.CalTotalCents() >= 100) Then dollar = c1.CalTotalCents() \ 100 txtbxDollars.Text = CType(dollar, Integer) End If txtbxCents.Text = c1.CalTotalCents Mod 100 End Sub

End Class

Class Coin Collection


Public Class clsCoinCollection
Private pennies, nickles, dollars, change, totalCent As Integer Public Sub SetValues(Optional ByVal p As Integer = 0, Optional ByVal n As Integer = 0, Optional ByVal d As Integer = 0, Optional ByVal c As Integer = 0, Optional ByVal t As Integer = 0) pennies = p nickles = n dollars = d change = c totalCent = t End Sub Public Function CalTotalCents() As Integer Return 5 * nickles + pennies End Function

End Class

You might also like