0% found this document useful (0 votes)
11 views

Assignment 3

Uploaded by

fukchuntse
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Assignment 3

Uploaded by

fukchuntse
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

CSCI1580 Visual Programming

Assignment 3
Deadline: 8-Nov-2022 (Tue) 23:59

Objectives
This assignment allows you to practice using arrays.

Task
Given a list of integers, the mode is the integer that appears most frequently. For example, the mode of
the list of integers [1, 3, 3, 1, 4, 4, 5, 4] is 4. In some cases, it is possible that there is more than one
mode. For example, there are three modes in the list of integers [16, 10, 10, 11, 11, 15, 16] and they are
10, 11, and 16.

In this assignment, your task is to write a Visual Basic console application to first read an integer n from
the user, then read n integers, and output the mode and the frequency. If there are two or more modes,
please print all of them in ascending order.

However, if the frequencies of all numbers are the same, the program will display the message “The
frequencies of all numbers are the same.” Instead. Some examples are [1, 2 ,3, 4, 5], [1, 1, 2, 2, 3, 3],
and [1, 1, 1].

You can assume all user inputs are always valid, 1 ≤ n ≤ 100, and all n integers are between -1000 and
1000 inclusively.

1
Sample Run
Underlined bold characters in blue are inputs from the user.

Sample Run 1 Sample Run 2


Enter n: Enter n:
6 8
Enter integer(s): Enter integer(s):
6 2
-1000 1
-1000 2
6 1
1000 -1000
-1000 1000
Mode(s): -1
-1000 x 3 -1
Mode(s):
-1 x 2
1x2
2x2
Sample Run 3 Sample Run 4
Enter n: Enter n:
5 1
Enter integer(s): Enter integer(s):
1 1
2 Mode(s):
3 The frequencies of all numbers are the same.
4
5
Mode(s):
The frequencies of all numbers are the same.

Assessment Scheme
 Correctness 90%
 Program readability (E.g., comments, meaningful variable names) 10%

Testing Platform
Microsoft Visual Studio Community 2022, Windows 10

Saving the Project Files


Please use “Save All” to save all the project files in one location but not “Save <file_name>.vb As” to
save some files in other locations. Otherwise, we may not be able to open your submission successfully.

2
Declaration
As required by the University, please place the following declaration as the comment in the beginning of
your VB source code.

' CSCI1580 Visual Programming


'
' Assignment <assignment_number>
'
' I declare that the assignment here submitted is original except for source
' material explicitly acknowledged. I also acknowledge that I am aware of
' University policy and regulations on honesty in academic work, and of the
' disciplinary guidelines and procedures applicable to breaches of such policy
' and regulations, as contained in the following University website:
' http://www.cuhk.edu.hk/policy/academichonesty/.
'
' Student Name: <your_name>
' Student ID: <your_student_ID>
' Date: <date>

Submission
Please follow the following steps to submit your work.

Step 1: Zip your Visual Basic project folder into a zip file Assg3_<your_student_id>.zip, where
<your_student_id> should be replaced by your student ID (e.g., Assg3_1234567890.zip).

The default project folder for Visual Studio 2022:

C:\Users\<user_name>\source\repos\<project_name>

Step 2: Go to BlackBoard and login your account by using your OnePass (CWEM) password.

Step 3: Go to the page for CSCI1580, choose Assignments => Assignment 3

Step 4: Upload your zip file prepared in Step 1.

Resubmissions are allowed. But only the latest one will be counted. 10% of your marks will be
deducted for late submission each day after the deadline. Late submissions more than three days will
not be graded.

You might also like