binibiningtinamoran

Money

Oct 12th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.47 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Money {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.         Scanner keyboard = new Scanner(System.in);
  8.  
  9.         String rating, country, response, exchange;
  10.         int income;
  11.         double corruptionIndex, inflation, taxRevenue;
  12.  
  13.         System.out.print("Enter the country name: ");
  14.         country = keyboard.nextLine();
  15.         System.out.print("Enter the per-capita income (integer): ");
  16.         income = Integer.parseInt(keyboard.nextLine());
  17.  
  18.         if (income < 10000) {
  19.             System.out.print("Do you have any history of default? (Y/N) ");
  20.             response = keyboard.nextLine();
  21.  
  22.             if (response.toLowerCase().charAt(0) == 'y') {
  23.                 rating = "DDE";
  24.             } else {
  25.                 System.out.print("Enter corruption index score (integer): ");
  26.                 corruptionIndex = Double.parseDouble(keyboard.nextLine());
  27.  
  28.                 if (corruptionIndex < 32) {
  29.                     rating = "CCE";
  30.                 } else if (corruptionIndex >= 32 && corruptionIndex < 48) {
  31.                     rating = "CCD";
  32.                 } else {
  33.                     rating = "CCC";
  34.                 }
  35.             }
  36.         } else if (income < 50000) {
  37.             System.out.print("Enter the country's Inflation rate (floating-point):");
  38.             inflation = Double.parseDouble(keyboard.nextLine());
  39.  
  40.             if (inflation > 1.9) {
  41.                 System.out.print("Enter the variability of exchange rate (Low/Medium/High) ");
  42.                 exchange = keyboard.nextLine();
  43.  
  44.                 if (exchange.toLowerCase().charAt(0) == 'h') {
  45.                     rating = "BBE";
  46.                 } else if (exchange.toLowerCase().charAt(0) == 'm') {
  47.                     rating = "BBD";
  48.                 } else {
  49.                     rating = "BBC";
  50.                 }
  51.             } else {
  52.                 rating = "BBB";
  53.             }
  54.         } else {
  55.             System.out.print("Enter the country's tax revenue as a percentage of GDP (floating-point): ");
  56.             taxRevenue = Double.parseDouble(keyboard.nextLine());
  57.             if (taxRevenue >= 23.5) {
  58.                 rating = "AAA";
  59.             } else if (taxRevenue < 23.5 && taxRevenue >= 11.2) {
  60.                 rating = "AAB";
  61.             } else {
  62.                 rating = "AAC";
  63.             }
  64.         }
  65.         System.out.println("Country: " + country);
  66.         System.out.println("Debt rating: " + rating);
  67.     }
  68. }
Add Comment
Please, Sign In to add comment