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 1 MB: Free
1 MB -1 GB: 100 Baht
More than 1 GB to 4 GB: 200 Baht
More than 4 GB to 10 GB: 300 Baht
More than 10 GB: 400 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+1 lines, each line containing at most 80 characters.
The first line receives a positive integer N, indicating the total number of data, not exceeding 100 entries (1<= N <=100).
The second to N+1 lines receive values Ui Bi (there is at least one space between Ui and Bi). Here, Ui is the username, consisting of up to 20 characters, and Bi is the usage data in bytes, a positive integer not exceeding 15 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 0 Baht.
Example 1
Input
3
Rafael 165000000
Serena 2012030
Roger 4056100
Output
Roger 200
Serena 200
Rafael 400
Example 2
Input
4
Pathom 189234567819234
Puttipong 1000
Nakon -2000
Orathai 23095678
Output
Nakon Free
Puttipong Free
Orathai 400
Pathom 400

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!