Question: Use java NetPayment One internet service provider offers the following service rates: Less than 1 MB: Free 1 MB - 1 GB: 1 0 0
Use java
NetPayment
One internet service provider offers the following service rates:
Less than MB: Free
MB GB: Baht
More than GB to GB: Baht
More than GB to GB: Baht
More than GB: Baht
Your task is to write a program to receive usage data of various users and process the data according to the following specifications:
Input
The input consists of N lines, each line containing at most characters.
The first line receives a positive integer N indicating the total number of data, not exceeding entries N
The second to N lines receive values Ui Bi there is at least one space between Ui and Bi Here, Ui is the username, consisting of up to characters, and Bi is the usage data in bytes, a positive integer not exceeding digits, for user i The input data in each field conforms to the specified format, so there is no need to validate the input format.
Output
The output consists of N lines, each line containing the user's name and the amount to be paid, separated by a single space. The results should be sorted in ascending order of the payment amount. In case of tied amounts, sort the names alphabetically.
Note
Due to potential issues with the input and output system, validate the correctness of the data. If the usage data is negative, consider it an error and display the service fee as Free. For users with a free service fee, consider it as Baht.
Example
Input
Rafael
Serena
Roger
Output
Roger
Serena
Rafael
Example
Input
Pathom
Puttipong
Nakon
Orathai
Output
Nakon Free
Puttipong Free
Orathai
Pathom
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
