按照規定,在高速公路上行使的機動車,超出本車道限速的10%則處200元罰款;若超出50%,就要吊銷駕駛證。請編寫程序根據車速和限速自動判別對該機動車的處理。
輸入格式:輸入在一行中給出2個正整數,分別對應車速和限速,其間以空格分隔。
輸出格式:在一行中輸出處理意見:若屬于正常行駛,則輸出“OK”;若應處罰款,則輸出“Exceed x%. Ticket 200”;若應吊銷駕駛證,則輸出“Exceed x%. License Revoked”。其中x是超速的百分比,精確到整數。
輸入樣例1:65 60輸出樣例1:OK
輸入樣例2:110 100
輸出樣例2:Exceed 10%. Ticket 200
輸入樣例3:200 120
輸出樣例3:Exceed 67%. License Revoked
import java.util.Scanner; public class Main {public static void main(String[] args){Scanner input = new Scanner(System.in);String inputs = input.nextLine();String[] a = inputs.split(" ");int length = a.length;int b[] = new int[length]; for(int m = 0;m < length;m++){b[m] = Integer.parseInt(a[m]);}double x = (b[0] - b[1]) * 100.0 / b[1];if(x < 10){System.out.print("OK");}elseif(x < 50){System.out.print("Exceed "+Math.round(x)+"%. Ticket 200");}else{System.out.print("Exceed "+Math.round(x)+"%. License Revoked");} } }
?