Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are developing an application for an investment company that needs to categorize investment opportunities for sovereign debt (i.e., debt owed by a central government,

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
You are developing an application for an investment company that needs to categorize investment opportunities for sovereign debt (i.e., debt owed by a central government, such as US Treasury Bonds), and assign credit ratings based on the country's financial attributes, and related information. This assignment is based loosely on the following research paper: Constantin Mellios & Eric Paget-Blanc (2006) Which factors determine sovereign credit ratings?, The European Journal of Finance, 12:4, 361 The table below summarizes the data used to describe countries: Country Descriptor Input Type Per-capita income Integer Range of Expected 681 to 124,927 1.4% to 75.82% 2.5 to 4,000,000 Name Values How much income does the average person in the How much of a country's income comes from taxes? Rate of How widely does the country's exchange rate earn? Tax revenue as a Double rcentage of GDP Inflation rate Variability of excha History of default Double Text of prices in a count Low, Medium, High rate Text Yes or No Has the country defaulted on debt in the 100 (fully transparent) to 0 (fully corrupt) Index of a country's transparency and governance structures Integer Perception Index The inputs into the application are data points describing the country, and the output is a three- character credit rating. The relevant decision tree is given in the figure below -500001 ncome? delaut? 11.2 P#48 Rang DDE Ruing AAA Raing AAC Raing AA Rating CCE Raing CCC Rating CCD Rating BB Rating BC Your task will be to follow the decision tree above to assign credit ratings to countries. Things you must make sure you do in your code: o Use nested conditional statements to encode the decision tree o Use only the nextLine Scanner method to read input from the user. This will avoid the issue with the extra new line character when reading text after numbers with nextint() or nextDouble(). The nextLine) method will produce a String from the input. You should use the hints for handling input below to convert from String to numeric data. Compute all the conditional logic, and then print the rating. print the rating at the end of your program. Do not print ratings from inside your conditional logic. Make sure your prompts and output messages match the sample output. o Use only one printin to o Things you may not do in your code: Your classification routine will be only a small part of a larger program, so you may not use the System.exit) or any similar method to terminate any of the conditional logic branches. o o Do not test for the same condition more than once, i.e., in the nested "else-if section do not test what you already tested in the "if" above. .Hints for handling input: o For text-based country data: Test only on the basis of the first letter of each choice. For example, if you are expecting "Yes" or "No" responses, you should use only the first character in differentiating the responses. (All text responses have different starting characters for any given decision point to make this possible.) Accept both upper- and lower-case letters for each choice. Consider the String method equalsignoreCase(String) for text comparisons, or use case conversion methods to convert to upper or lower case. " For simplicity, you do not have to do error checking of user input. If the user enters unexpected text values (e.g, "Jinstead of Y or "N"), your code may (depending on how you have implemented it) assign the default rating, or assign no rating, or give a runtime error. This is ok. You are not responsible for errors in these cases. o For integer country data: "The nextLine ) method will return a String. To convert from String to integer, use the Integer.parseInt (String) method. Example: String numberAsString-"3940 . int numberAsint Integer.parselnt(numberAsString): o For floating point country data: " The nextLine ) method will return a String. To convert from String to double, use the Double.parseDouble (String) method. Example: String numberAsString "3.61 double numberAsDouble- Double.parseDouble(numberAsString Instructions: 1. Declare a rating variable as a String, and initialize it as needed. Do this before starting the conditional logic. Create a Scanner object for reading values from the keyboard. Do this before starting the conditional logic-you can create the Scanner variable once at the top of your code, and reuse the same Scanner variable for reading all the values throughout your conditional logic. You should not create multiple Scanner objects throughout your code. Prompt the user for country name and store it in a variable. At the end of your classification, print the country name to the screen before you print the rating. Prompt the user for country information, store it in appropriate variables, and use the values to make decisions. Nest your conditional logic appropriately to reach each decision point. Ask for the input only if it is relevant to the situation, for example, do not ask for the history of default if the country has a per-capita income above 50,000. 2. 3. 4. First, prompt the user to enter the country's per-capita income, and read the input. Store in a variable and make a classification decision. a. Hint: Assume that one of the options is a default. Check for the first 2 of the 3 options, and assume it is the 3rd option as a default if the input does not match either of the first 2. b. When appropriate, prompt for history of default, and read the input. Store the input in a variable, and make a classification decision. When appropriate, prompt for tax revenue as a percentage of GDP, and read the input. Store the input in a variable, and make a classification decision. When appropriate, prompt for inflation rate, and read the input. Store the input in a variable, and make a classification decision. When appropriate, prompt for Corruption Perception Index score, and read the input. Store the input in a variable, and make a classification decision. c. d. e. f. When appropriate, prompoiability of exchange rate and read the input. Store the input in a variable, and make a classification decision. 5. After the classification task is done, you should have a rating variable set to the appopriate credit rating for the input values. Print the credit rating, following the sample output. The print Sample Output: run: Enter the country name: Norway Enter the per-capita income (integer) 70500 Enter country's tax revenue as a percentage of GDP (floating-point): 54.8 Country: Norway Debt rating: AAA BUILD SUCCESSFUL (total time: 46 seconds) run: Enter the country name: Kuwait Enter the per-capita income (integer): 69700 Enter country's tax revenue as a percentage of GDP (floating-point): 1.5 Country: Kuwait Debt rating: AAC BUILD SUCCESSFUL (total time: 34 seconds) run: Enter the country name: Hong Kong Enter the per-capita income (integer): 61000 Enter country's tax revenue as a percentage of GDP (floating-point): 13.0 Country: Hong Kong Debt rating: AAB BUILD SUCCESSFUL (total time: 35 seconds) run: Enter the country name: France Enter the per-capita income (integer): 43600 Enter the country's inflation rate (floating-point): 1.2 Country:France Debt rating: BBB BUILD SUCCESSFUL (total time: 31 seconds

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions