A Jewellery Store Needs a Program to Calculate the Cost of Engraving Names Or Messages

A Jewellery Store Needs a Program to Calculate the Cost of Engraving Names Or Messages

<p>Practical Test Question 1</p><p>A company needs a program to help calculate the Yearly Bonus for each employee. The Yearly Bonus is determined by considering several different factors. The first factor is the Number of Years a person has been employed by the firm. Being employed for 1 to 5 years adds R100.00 to the bonus, being employed for 6 to 10 years adds R200.00 to the bonus, and being employed for 11 or more years adds R350.00 to the bonus. (Use Radiobuttons for input) </p><p>In addition to the Number of Years, an employee's Work Grade is considered. For Work Grade 1, R75.00 is added to the bonus; for Work Grade 2, R100.00 is added to the bonus; and for Work Grade 3, R125.00 is added to the bonus. Also, if an employee has participated in community service (Parcipation = "Y"), then an additional R100.00 is added to the bonus. And finally, 5 percent of the employee's Current Salary is computed and added to the bonus. (Use Radiobuttons for input) </p><p>Use the given flowchart and code the program into Visual Basic.Net (Save as Student number frm1)</p><p>Start</p><p>Read Participation, Current Salary</p><p>Number of True Yearly Bonus = Years <= 5 100.00</p><p>False</p><p>Number of True Yearly Bonus = Years <= 10 200.00</p><p>False</p><p>Yearly Bonus = 350.00</p><p>Yearly Bonus = Work Grade = True Yearly Bonus + 1 75.00</p><p>False</p><p>Yearly Bonus = Work Grade = True Yearly Bonus + 2 100.00</p><p>False</p><p>Yearly Bonus = Yearly Bonus + 125.00</p><p>Yearly Bonus = Participation = True Yearly Bonus + “Y” 100.00 False</p><p>Yearly Bonus = Yearly Bonus + (CurrentSalary * 0.05)</p><p>Write Yearly Bonus</p><p>Stop MEMO</p><p>Private Sub btnCalculateBonus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculateBonus.Click Dim Salary, Bonus As Double Dim Participation As String Salary = txtSalary.Text</p><p>If rad1to5.Checked Then Bonus = 100 If radWG1.Checked Then Bonus = Bonus + 75 ElseIf radWG2.Checked Then Bonus = Bonus + 100 Else Bonus = Bonus + 125 End If ElseIf rad6to10.Checked Then Bonus = Bonus + 200 If radWG1.Checked Then Bonus = Bonus + 75 ElseIf radWG2.Checked Then Bonus = Bonus + 100 Else Bonus = Bonus + 125 End If Else Bonus = 350 If radWG1.Checked Then Bonus = Bonus + 75 ElseIf radWG2.Checked Then Bonus = Bonus + 100 Else Bonus = Bonus + 125 End If End If Participation = InputBox("Participate in community service? Y or N", "PARTICIPATION") If Participation.ToUpper = "Y" Then Bonus = Bonus + 100 End If Bonus = Bonus + (Salary * 0.05) lblOutput.Text = "Yearly bonus: " & FormatCurrency(Bonus) End Sub Question 2</p><p>A Jewellery Store needs a program to calculate the cost of engraving names or messages on jewellery items or trophies. </p><p>The program should continually accept and calculate the cost of names or messages to be engraved. To end this process it is required that “---“ is typed as the message to signal that the repeated process is stopped.</p><p>Once the program accepts the name or message to be engraved as input, it should determine how many characters there are in this name or message. Allow the program to analyze the name or message, character by character (letter by letter). Use the following guidelines:</p><p>First Five Letters (characters): For the first five letters the cost is a total of R20. Take note that if one of the first five letters happens to be a capital letter, an additional R2 fee is charged, per capital letter, on the R20 whereas a space will be treated as a lower case character. </p><p>Remaining Letters (characters): Every letter after the fifth letter is charged at R5 per lowercase letter, R7 per uppercase letter and R1 for a space. (Save as Student number frm2)</p><p> frmHead1 frmHead2 frmBody</p><p> lstReport</p><p> btnCalc btnExit Use the following: Dim frmHead1 As String = "{0,-15}{1,-7}{2,-12}{3,-26}{4,8}" Dim frmHead2 As String = "{0,-15}{1,-7}{2,-12}{3,-8}{4,-10}{5,-8}" Dim frmBody As String = "{0,-17}{1,-7}{2,-12}{3,-8}{4,-10}{5,-8}{6,8:C2}" Enter if msg = Start yes Stop msg "- - -"</p><p> no</p><p> initialize totals</p><p> no Determine msg length</p><p> if length > 0</p><p> yes</p><p> price = 20 Display i = 1 message, totals and price</p><p>Do until yes i > length</p><p> no</p><p>Extract one character</p><p> if if if yes no charac = i <= 5 charac = space capital</p><p> yes yes</p><p>Add R2 to price no Add nothing Add 1 to totCapFive</p><p> no</p><p> if if if if yes no charac = no charac = lower i > 5 charac = space capital case</p><p> yes yes yes</p><p>Add R1 to price Add R7 to price Add R5 to price Add 1 to Add 1 to Add 1 to no totSpaces totCapRest totLowRest</p><p> no</p><p> increment i by 1 SOLUTION</p><p>Dim message, charac As String Dim NrChar, i As Integer Dim price As Double Dim totCapFive, totCapRest, totLowRest, totSpaces As Integer Dim frmHead1 As String = "{0,-15}{1,-7}{2,-12}{3,-26}{4,8}" Dim frmHead2 As String = "{0,-15}{1,-7}{2,-12}{3,-8}{4,-10}{5,-8}" Dim frmBody As String = "{0,-17}{1,-7}{2,-12}{3,-8}{4,-10}{5,-8}{6,8:C2}" lstReport.Items.Add(String.Format(frmHead1, "Message", "Total", "First Five", "Remaining", "Cost")) lstReport.Items.Add(String.Format(frmHead2, "", "", "Capital", "Capital", "Lowercase", "Spaces")) lstReport.Items.Add(" ")</p><p> message = InputBox("Enter name or message to be engraved") Do Until message = "---" totCapFive = 0 totCapRest = 0 totLowRest = 0 totSpaces = 0 NrChar = Len(message) If NrChar > 0 Then price = 20 For i = 1 To NrChar charac = message.Substring(i - 1, 1) If i <= 5 Then If charac = " " Then 'do nothing ElseIf charac = charac.ToUpper Then price = price + 2 totCapFive = totCapFive + 1 End If Else If charac = " " Then price = price + 1 totSpaces = totSpaces + 1 ElseIf charac = charac.ToUpper Then price = price + 7 totCapRest = totCapRest + 1 ElseIf charac = charac.ToLower Then price = price + 5 totLowRest = totLowRest + 1 End If End If Next End If lstReport.Items.Add(String.Format(frmBody, message, NrChar, totCapFive, totCapRest, totLowRest, totSpaces, price))</p><p> message = InputBox("Enter name or message to be engraved") Loop</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    6 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us