0% found this document useful (0 votes)
10 views3 pages

Title Background Program Specifications: Lưu ý: Bài quy đổi ra 2 slot short hoặc 1 slot Long

This document provides specifications for a program to: 1. Allow users to input person information including name, address, and salary. Salary must be validated as a number. 2. Sort the list of people by salary in ascending order. 3. Display information for the top 3 people by salary. The program should include functions for inputting person data, displaying person information, and sorting the person array by salary. Sample input/output screens are provided along with examples of how to structure the code using a Person class.

Uploaded by

thiendaica586
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)
10 views3 pages

Title Background Program Specifications: Lưu ý: Bài quy đổi ra 2 slot short hoặc 1 slot Long

This document provides specifications for a program to: 1. Allow users to input person information including name, address, and salary. Salary must be validated as a number. 2. Sort the list of people by salary in ascending order. 3. Display information for the top 3 people by salary. The program should include functions for inputting person data, displaying person information, and sorting the person array by salary. Sample input/output screens are provided along with examples of how to structure the code using a Person class.

Uploaded by

thiendaica586
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/ 3

ID: FA21_07

Lưu ý: Bài quy đổi ra 2 slot short hoặc 1 slot Long

Title
Input and display Person Info.
Background
N/A
Program Specifications
Write a program allow user to input and sort person information (name, address, salary)
- Validate salary is a number or not

- Sort Person list ascending

- Show 3 person information by ascending of salary

Function details:
Function 1: Display Gui And Input Data.
 Users run the program. The program prompts users input Data.

 Auto next Function2.

Function 2: Perform function


 Program display input information

 Sort person list by salary ascending and exit program

Expectation of User interface:

=====Management Person programer===== Information of Person you have entered:


Input Information of Person Name:LienVT
Please input name:NghiaNV Address:HaNoi
Please input address:HaNoi Salary:500.0
Please input salary:abc
You must input digidt. Information of Person you have entered:
Please input salary:-2000 Name:TuanNT
Salary is greater than zero Address:HaNoi
Please input salary:2000 Salary:1000.0
Input Information of Person
Please input name:LienVT Information of Person you have entered:
Please input address:HaNoi Name:NghiaNV
Please input salary:500 Address:HaNoi
Input Information of Person Salary:2000.0
Please input name:TuanNT
Please input address:HaNoi
Please input salary:1000

Guidelines
Student must implement methods
- inputPersonInfo

- displayPersonInfo
ID: FA21_07

- sortBySalary

in startup code.
Example:
Create a class named Person with properties:
private String name;
private String address;
private double salary;
+ Create constructors: name, address, salary
+ Create get/set functions for Person properties
+ Create function Person inputPersonInfo(String name, String address, String sSalary):
- Validate salary is a number or not.

- If salary is not a number, prompt use to re-input and show error message that salary must be a number.

- If salary is a negative number prompt use to re-input and show error message that salary must be a positive
number.

+ Create a functiondisplayPersonInfo(Person person)


- Display person properties

+ Create Person[] sortBySalary(Person[] person):


Sort person by BubbleSort algorithm
+ Create an array of 3 person.
Function 1:Input Person information
o Program prompt user to input name, address, salary of Person

o Create a function: Person inputPersonInfo (String name,String address, String sSalary) throws Exception

 Input:

 name: name of Person

 address: addressof Person

 salary: salary of Person

 Return value:

 Person object.

 Exception("Salary is greater than zero"); if input invalid

 Exception("You must input Salary."); if input invalid

 Exception("You must input digit."); if input invalid

Function 2:Display Person information.


o Program show all Person properties just input

o Create a function: void displayPersonInfo(Person person)


ID: FA21_07

 Input:

 person: Person object

Function 3: Sort Person array by salary ascending.


o Program display all Person properties sort by Person’s salary

o Create function: Person[] sortBySalary(Person[] person) throws Exception

 Input:

 person: Person array need to be sorted.

 Return value:

 Person array sorted by salary.

 Exception("Can't Sort Person"); If there a errors

You might also like