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 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...
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...
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)
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)
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...
This is a programming assignment!!! Start with the Assignment3.java source code posted to Canvas. This code...
This is a programming assignment!!! Start with the Assignment3.java source code posted to Canvas. This code outputs the programmer’s name , prompts the user to enter two numbers (integers) and outputs their sum. Note: When you run the program, it expects you to enter two integer values (a counting or whole number like 1, 216, -35, or 0) Make the following changes/additions to the code: On line 11, change the String myName from “your full name goes here!!!” to your...
Question: Can I get the code in Java for this assignment to compare? Please and thank you....
Question: Can I get the code in Java for this assignment to compare? Please and thank you. Can I get the code in Java for this assignment to compare? Please and thank you. Description Write a Java program to read data from a text file (file name given on command line), process the text file by performing the following: Print the total number of words in the file. Print the total number of unique words (case sensitive) in the file. Print...
The purpose of this assignment is to develop your ability to code and understand ArrayLists. We...
The purpose of this assignment is to develop your ability to code and understand ArrayLists. We will do this by taking a do-it-yourself (DIY) approach by building our own ArrayList-Like data structure called "ArrayBox". You must: Create a generic class called ArrayBox that uses an ARRAY to store its objects. Assume the initial size of the array is two(2). Your ArrayBox must automatically double the size of your elements array when it becomes full as described in class (see slides)....
Language for this question is Java write the code for the given assignment Given an n...
Language for this question is Java write the code for the given assignment Given an n x n matrix, where every row and column is sorted in non-decreasing order. Print all elements of matrix in sorted order.Input: The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an integer n denoting the size of the matrix. Then the next line contains the n x n elements...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT