3 of 3
Paper No: 1
3. Class CircleTest
Build program that read input file and print out the result into output file as following rule:
The input: are stored in the input.txt text file:
The first line contains a positive integer T (1≤T≤100) which is the number of test case.
The next T line contains one of 4 type:
1. Circle x y radius, when the line start with a string "Circle", the program will add new Circle (x, y, radius) and print out the string "Add Circle (x,y, radius)".
2. Show, when the line start with a string "Show", the program will print out information
of all circles as the sample.3. Clear, when the line contains only a string "Clear", the program will remove all Circle that added and print out the string "@ Remove all circle".
4. Sort, when the line contains only a string "Sort", the program will sort all circle ascending based on area and print out information of all circles after sorted.
The output: all result must be print out into the output.txt file.
Sample 1
input.txt
5
Circle 2 4 2.5
Circle 5-7 1
Show
Sort Clear
output.txt
Add Circle (2,4,2.50)
Add Circle (5,-7,1.00)
+++Show+++
Circle(Center{x-2,y-4},radius-2.50, diameter-5.00,circumference-15.71,area-19.63}Circle(Center{x=5,y=-7), radius=1.00, diameter-2.00,circumference-6.28, area 3.14)
***Sort***
Circle (Center{x=5,y=-7), radius=1.00, diameter-2.00,circumference-6.28, area 3.14)
Circle(Center(x=2,y=4), radius=2.50, diameter-5.00,circumference=15.71,area=19.63)