Question

In: Computer Science

Assignment Content Resource: ****************************CODE PASTED BELOW******************************* For this assignment, you will develop Java™ code that relies...

Assignment Content

  1. Resource:

    • ****************************CODE PASTED BELOW*******************************

    For this assignment, you will develop Java™ code that relies on localization to format currencies and dates.

    In NetBeans, copy the linked code to a file named "Startercode.java".

    Read through the code carefully and replace all occurrences of "___?___" with Java™ code.

    Note: Refer to "Working with Dates and Times" in Ch. 5, "Dates, Strings, and Localization," in OCP: Oracle® Certified Professional Java® SE 8 Programmer II Study Guide for help.

    Run and debug your JAVA file to ensure that your solution works.

************************ CODE *****************************

package code;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.util.Currency;
import java.util.Date;
import java.util.__?__;

public class Startercode {
public static void main(String[] args) {
long number = 5000000L;

NumberFormat numberFormatDefault = NumberFormat.getInstance();
System.out.println("Number Format using Default Locale: "+numberFormatDefault.format(number));
NumberFormat numberFormatLocale = NumberFormat.getInstance(Locale.__?__);
System.out.println("Number Format using _?__Locale: "+numberFormatLocale.format(number));

NumberFormat numberFormatDefaultCurrency = NumberFormat.getCurrencyInstance();
System.out.println("Currency Format using Default __?__:   
"+numberFormatDefaultCurrency.format(number));

NumberFormat numberFormatLocaleCurrency = NumberFormat.getCurrencyInstance(Locale.__?_);

System.out.println("Currency Format using __?__ Locale: "+numberFormatLocaleCurrency.format(number));

Currency currency = Currency.getInstance(L___? . ___?__);
System.out.println(currency.getDisplayName()+" ("+currency.getCurrencyCode()+")
"+currency.getDisplayName());
  
Date currentDate = new Date();
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.FULL, Locale.__?__);
System.out.println("Date Format in __?__ Locale: "+dateFormat.format(currentDate));

}

  
}

Solutions

Expert Solution

package code;

import java.text.DateFormat;

import java.text.NumberFormat;

import java.util.Currency;

import java.util.Date;

import java.util.Locale; //import the Locale library

public class Startercode {

       public static void main(String[] args) {

             long number = 5000000L;

      

             NumberFormat numberFormatDefault = NumberFormat.getInstance(); // gets the default locale format

             System.out.println("Number Format using Default Locale: "+numberFormatDefault.format(number));

             NumberFormat numberFormatLocale = NumberFormat.getInstance(Locale.US); // returns the number format in US locale

             System.out.println("Number Format using US Locale: "+numberFormatLocale.format(number));

      

             NumberFormat numberFormatDefaultCurrency = NumberFormat.getCurrencyInstance(); // get the currency format in default locale

             System.out.println("Currency Format using Default Locale :   "+numberFormatDefaultCurrency.format(number));

      

             NumberFormat numberFormatLocaleCurrency = NumberFormat.getCurrencyInstance(Locale.US); // get the currency format in US locale

      

             System.out.println("Currency Format using US Locale: "+numberFormatLocaleCurrency.format(number));

      

             Currency currency = Currency.getInstance(Locale.US); // returns the currency instance for given locale

             System.out.println(currency.getDisplayName()+" ("+currency.getCurrencyCode()+")"+currency.getDisplayName());

                   

             Date currentDate = new Date();

             DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.FULL, Locale.getDefault()); // get the date instance for default locale

             System.out.println("Date Format in Default Locale: "+dateFormat.format(currentDate));

             }

}

//end of program

Output:


Related Solutions

Using JAVA and NETBEANS Assignment Content For this assignment, you will develop "starter" code. After you...
Using JAVA and NETBEANS Assignment Content For this assignment, you will develop "starter" code. After you finish, your code should access an existing text file that you have created, create an input stream, read the contents of the text file, sort and store the contents of the text file into an ArrayList, then write the sorted contents via an output stream to a separate output text file. Copy and paste the following Java™ code into a JAVA source file in...
For this assignment, you will be analyzing the Java™ code in the linked Week 3 Analyze...
For this assignment, you will be analyzing the Java™ code in the linked Week 3 Analyze Assignment Zip File, and predicting the results. You will also examine both the code and the output for inconsistencies and clarity. This Java™ code includes examples of for, while, and do-while loops. Carefully read through the code line by line, then answer the following questions in a Microsoft® Word document: What is the output of the program as it is written? What improvement(s) could...
For this assignment, you will apply what you learned in analyzing Java™ code so far in...
For this assignment, you will apply what you learned in analyzing Java™ code so far in this course by writing your own Java™ program. The Java™ program you write should do the following: Accept user input that represents the number of sides in a polygon. Note: The code to do this is already written for you. If input value is not between 3 and 5, display an informative error message If input value is between 3 and 5, use a...
Using JAVA Resource: "Analyze and Document JDBC API Calls" text file ** PASTED BELOW** For this...
Using JAVA Resource: "Analyze and Document JDBC API Calls" text file ** PASTED BELOW** For this assignment, you will analyze code that uses the JDBC API to access a database, retrieve data, and compose output based on that data. You will then comment the code to reflect the purpose and expected results of the code. Download the linked TXT file, and read through the Java™ code carefully. Add your name, instructor's name, and today's date to the header comment. Replace...
For this assignment, you will apply what you learned in analyzing a simple Java™ program by...
For this assignment, you will apply what you learned in analyzing a simple Java™ program by writing your own Java™ program. The Java™ program you write should do the following: Display a prompt on the console asking the user to type in his or her first name Construct the greeting string "Hello, nameEntered!" Display the constructed greeting on the console Complete this assignment by doing the following: Download and unzip the linked zip file. Add comments to the code by...
Invalid entry code in python my code is pasted below. The last elif statement, I'm trying...
Invalid entry code in python my code is pasted below. The last elif statement, I'm trying to get the program to print "invalid entry" if the entry for user_input is invalid. The first user prompt should only allow for numbers 1-10 and "exit" and "quit" import math user_prompt = """Enter number of operation that you want to execute <type exit or quit to end program>: 1 sin(x) 2 cos(x) 3 tan(x) 4 asin(x) 5 acos(x) 6 atan(x) 7 ln(x) 8...
PLEASE CODE IN JAVA In this assignment you will write a program in that can figure...
PLEASE CODE IN JAVA In this assignment you will write a program in that can figure out a number chosen by a human user. The human user will think of a number between 1 and 100. The program will make guesses and the user will tell the program to guess higher or lower.                                                                   Requirements The purpose of the assignment is to practice writing functions. Although it would be possible to write the entire program in the main function, your...
Give the entire code for Minimum spanning tree using Boruvka's algorithm in java (not copy-pasted from...
Give the entire code for Minimum spanning tree using Boruvka's algorithm in java (not copy-pasted from any other website)
Wk 2 - Compensation Evaluation Assignment Content Resource: Compensation Evaluation Grading Guide You were hired to...
Wk 2 - Compensation Evaluation Assignment Content Resource: Compensation Evaluation Grading Guide You were hired to work as a HR consultant for a small local hospital, with the task of expanding the workforce of certified medical assistants. Looking at the current three employees, you find a discrepancy in compensation between Susi, a 2-year employee at $28,000; Tom, 5-year employee at $27,000; and Raul, a 10-year employee at $33,000. All are employed as certified medical assistants, yet they all earn different...
USE GENERICS TO WRITE THE JAVA CODE FOR THIS ASSIGNMENT In this assignment, rewrite two of...
USE GENERICS TO WRITE THE JAVA CODE FOR THIS ASSIGNMENT In this assignment, rewrite two of the following sorting methods (Insertion Sort, Selection Sort, Quick Sort, and Merge Sort) to sort ArrayList of objects using Comaprable interface. (60 points)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT