0% found this document useful (0 votes)
69 views7 pages

Sqit1013 Group 1 (Group Assignment 2)

The document discusses 5 programming questions. Question 1 identifies errors in code snippets and requires corrections. Question 2 involves writing code to accomplish tasks like summing odd integers in a range using loops. Question 3 is about developing a program to calculate salesperson earnings based on weekly gross sales and commissions. Question 4 involves computing the average price of 3 items, applying a discount if the average is over RM50, and displaying the net amount to pay.

Uploaded by

puteri hanis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views7 pages

Sqit1013 Group 1 (Group Assignment 2)

The document discusses 5 programming questions. Question 1 identifies errors in code snippets and requires corrections. Question 2 involves writing code to accomplish tasks like summing odd integers in a range using loops. Question 3 is about developing a program to calculate salesperson earnings based on weekly gross sales and commissions. Question 4 involves computing the average price of 3 items, applying a discount if the average is over RM50, and displaying the net amount to pay.

Uploaded by

puteri hanis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

UNIVERSITI UTARA MALAYSIA

SESSION 2021/2022 (A212)


SQIT1013 (A) PROGRAMMING IN BUSINESS APPLICATIONS

GROUP ASSIGNMENT 2

PREPARED FOR:
DR. SHANIZAN HERMAN BIN MOHD RADZI

PREPARED FROM:
GROUP 1

NAME MATRIC NO.

NUR ANIS SYAZLIANA BINTI SHAFIDAN 287932

AMIRA ATIKAH BINTI AHMAD ZULKARNAIN 288057

KHAIRINA BINTI KHAIRUDDIN 288221

PUTERI HANIS BIN MOHD RUDUWAN 288573


QUESTION 1

Identify and correct the error(s) in each of the following (you may simply need to add code) :
❖ Assume that z has been initialized to 50. The values from 0 to 50 should be totaled.
While (z>=0) {
sum += z;
Z--;
}

❖ Assume that y and total are declared as Integers


Dim y As Integer
Dim total As Integer
total = 0
Do Until y = -1
Print y
y = InputBox(“Enter a value, value input”)
total = total + y
Loop

❖ Assume that k is declared as an Integer. The loop should iterate until -1 is input.
Dim k As Integer
Do While k >= -1
InputBox(“Enter a number -1 to quit:”, VB6)
Loop

❖ Assume that y is declared as Variant


Dim y As Variant
For y = o.1 To 1.0 step .2
Print y
Next y

❖ Assume that the variable testVariable has been declared as Integer


Dim testVariable As Integer
testVariable = 10
Do
Print testVariable;
testVariable = testVariable +5
Loop Until testVariable = 50
Print
QUESTION 2
WRITE A STATEMENT OR A SET OF THE STATEMENTS TO ACCOMPLISH EACH OF
THE FOLLOWING:
● SUM THE ODD INTEGERS BETWEEN 25 AND 78 USING A FOR/ NEXT
STRUCTURE. ASSUME THAT VARIABLES SUM AND COUNT HAVE BEEN
DECLARED EXPLICITLY AS INTEGER.

Module Module1
Sub Main()
Dim sumOddIntegers As Integer = 0
For count As Integer = 25 To 78
If count Mod 2 = 1 Then
sumOddIntegers += count
End If
Next
Console.WriteLine("Sum the odd integers between 25 and 78: {0}", sumOddIntegers)

● PRINT THE NUMBER FROM 35 TO 20 ON THE FORM USING A DO UNTIL LOOP


AND INTEGER COUNTER VARIABLE X. ASSUME THAT THE VARIABLE X IS
INITIALISED TO 35.

Dim x As Integer = 35
Console.WriteLine("The number from 35 to 20:")
Do Until x < 20
Console.WriteLine(x.ToString())
x -= 1
Loop
● PRINT THE EVEN INTEGER FROM 1 TO 20 USING A DO/ LOOP WHILE
STRUCTURE AND THE COUNTER VARIABLE X

Console.WriteLine("The even Integers from 1 to 20:")


x=1
Do
If x Mod 2 = 0 Then
Console.WriteLine(x.ToString())
End If
x += 1
Loop While x <= 20

Console.ReadLine()
End Sub

End Module

QUESTION 2 INTERFACE
QUESTION 3
One large chemical company pays its salespeople on a commission basis. The
salespeople receive RM700 per week plus 9% of their gross sales for that
week. For example, a salesperson who sells RM10 000 worth of chemicals in a
week receives RM700 plus 9% of RM10000, or a total of RM1 600. Develop a
program that will input each salesperson's gross sales for last week and will
calculate and display the salesperson's earnings. Process one salesperson's
figures at a time.

Module Module1
Sub Main()
Console.Write("Enter salesperson's gross sales for last week:")
Dim grossSales As Double = Integer.Parse(Console.ReadLine())
Dim salespersonEarnings As Double = 700 + grossSales * 0.09
Console.WriteLine("The salesperson's earnings = RM{0}", salespersonEarnings.ToString("N"))
Console.ReadLine()

End Sub
End Module

QUESTION 3 INTERFACE
QUESTION 4

DEVELOP A SOLUTION TO COMPUTE THE AVERAGE PRICE FOR THREE ITEMS’


PRICE INPUT BY USER ONE AT A TIME. IF THE AVERAGE PRICE IS GREATER THAN
RM50, 10% DISCOUNT WILL BE GIVEN TO THE CUSTOMER. YOUR PROGRAM
SHOULD BE ABLE TO DISPLAY THE NETT AMOUNT THAT NEEDS TO BE PAID BY
THAT CUSTOMER.

Public Module program

Private Sub main(args() As String)

Dim price(3) As Integer

Dim a As Integer = 0

Dim i As Integer = 0

Dim sum As Double = 0

' Getting input from user

Console.WriteLine("Enter the price of three items: ")

For i = 0 To 2

price(i) = Convert.ToInt32(console.Readline())

Next i

Do

sum = sum + price(a)

a=a+1

Loop While (a < 3)

If (sum / 3 > 50) Then

sum = sum * 0.9 ' Giving 10% discount

End If

' Display the output

Console.WriteLine("you have to pay rm {0}", sum)

End Sub

End Module
QUESTION 4 INTERFACE

You might also like