Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Money {
- public static void main(String[] args) {
- Scanner keyboard = new Scanner(System.in);
- String rating, country, response, exchange;
- int income;
- double corruptionIndex, inflation, taxRevenue;
- System.out.print("Enter the country name: ");
- country = keyboard.nextLine();
- System.out.print("Enter the per-capita income (integer): ");
- income = Integer.parseInt(keyboard.nextLine());
- if (income < 10000) {
- System.out.print("Do you have any history of default? (Y/N) ");
- response = keyboard.nextLine();
- if (response.toLowerCase().charAt(0) == 'y') {
- rating = "DDE";
- } else {
- System.out.print("Enter corruption index score (integer): ");
- corruptionIndex = Double.parseDouble(keyboard.nextLine());
- if (corruptionIndex < 32) {
- rating = "CCE";
- } else if (corruptionIndex >= 32 && corruptionIndex < 48) {
- rating = "CCD";
- } else {
- rating = "CCC";
- }
- }
- } else if (income < 50000) {
- System.out.print("Enter the country's Inflation rate (floating-point):");
- inflation = Double.parseDouble(keyboard.nextLine());
- if (inflation > 1.9) {
- System.out.print("Enter the variability of exchange rate (Low/Medium/High) ");
- exchange = keyboard.nextLine();
- if (exchange.toLowerCase().charAt(0) == 'h') {
- rating = "BBE";
- } else if (exchange.toLowerCase().charAt(0) == 'm') {
- rating = "BBD";
- } else {
- rating = "BBC";
- }
- } else {
- rating = "BBB";
- }
- } else {
- System.out.print("Enter the country's tax revenue as a percentage of GDP (floating-point): ");
- taxRevenue = Double.parseDouble(keyboard.nextLine());
- if (taxRevenue >= 23.5) {
- rating = "AAA";
- } else if (taxRevenue < 23.5 && taxRevenue >= 11.2) {
- rating = "AAB";
- } else {
- rating = "AAC";
- }
- }
- System.out.println("Country: " + country);
- System.out.println("Debt rating: " + rating);
- }
- }
Add Comment
Please, Sign In to add comment