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 DescriptorInput T Per-capita income Integer Tax revenue as a TypeRange of Expected Description Values 681 to 124,927 1.4% to 75.82% 2.5 to 4,000,000 How much income does the average person in the c How much of a country's income comes from taxes? Rate of change of prices in a count How widely does the country's exchange rate earn? entage of GDP Inflation rate Variability of excha History of defaultTe Double Text Low, Medium, High Yes or No 100 (fully transparent) Index of a country's transparency and rate Has the country defaulted on debt in the Integer Perception Index core to O (fully corrupt) governance structures 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 P 50,000 10.000 and e 50.000 235 112 x revenue as delauit? 235 an112 48Ratng DDE Rating AA Raing AAG H Rating AAB Variabity in exchange rate Raing CCE Rating CC Rating BB8 Rang CCD Rating BBE Rating BC Rating BBo 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. Use only one println to 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 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. 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. o o Hints for handling input: o For text-based country data: Test only on the basis of the first letter of each choice. 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.) For example, if you are " "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 enters unexpected text values (e.g.. instead 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: e 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 to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions

Question

4. Identify the stage of the road of trials in The Wizard of Oz.

Answered: 1 week ago

Question

Differentiate 3sin(9x+2x)

Answered: 1 week ago

Question

Compute the derivative f(x)=(x-a)(x-b)

Answered: 1 week ago