Question

Resource: "The Locale Object" text file For this assignment, you will develop Java™ code that relies...

Resource:

  • "The Locale Object" text file

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.

Save your JAVA file with a .txt extension.

Submit your TXT file to the Assignment Files tab.

----

/**********************************************************************
*   Program:   Startercode
*    Purpose:    Class assignment:
* Students - Given starter code, students write code that uses the
* Locale object (language, country, etc.) *
*       The questions marks (?) in the code are to be completed by the students.
*       Add comments/documentation to the code lines
*   Programmer:   Iam A. student          
*   Class:       PRG/421r13, Java Programming II          
*   Instructor:   XXXXX          
*   Creation Date:   TODAY'S DATE  
*
*   Comments:
*       For additional information, refer to:
*       OCA/OCP Java SE7, Programmer I & II Study Guide
*       Chapter 8: String Processing, Data Formatting, Resource Bundles
*       Section: Working with Dates, Numbers, and Currencies
*  
***********************************************************************/

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));

}

  
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________

// Startercode.java

import java.text.DateFormat;
import java.text.NumberFormat;
import java.util.Currency;
import java.util.Date;
import java.util.Locale;

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.US);
System.out.println("Number Format using US Locale: "+numberFormatLocale.format(number));

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

NumberFormat numberFormatLocaleCurrency = NumberFormat.getCurrencyInstance(Locale.US);

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

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

}

  
}

____________________

Output:

Number Format using Default Locale: 5,000,000
Number Format using US Locale: 5,000,000
Currency Format using Default Locale:$5,000,000.00
Currency Format using US Locale: $5,000,000.00
US Dollar (USD)US Dollar
Date Format in US Locale: Sunday, April 21, 2019


_______________Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
Resource: "The Locale Object" text file For this assignment, you will develop Java™ code that relies...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • /************************************************************************************ * Program: PRG/420 Week 5 * Purpose: Week 5 Coding Assignment * Programmer: TYPE YOUR...

    /************************************************************************************ * Program: PRG/420 Week 5 * Purpose: Week 5 Coding Assignment * Programmer: TYPE YOUR NAME HERE * Class: PRG/420 * Creation Date: TYPE TODAY'S DATE HERE ************************************************************************************* * Program Summary: * This program converts a given date to a string. * The code includes exception handling for a ParseException. ************************************************************************************/ package prg420week5_codingassignment; import java.util.*; // wildcard to import all the util. classes import java.text.*; // wildcard to import all the text classes public class PRG420Week5_CodingAssignment { public static...

  • The following code uses a Scanner object to read a text file called dogYears.txt. Notice that...

    The following code uses a Scanner object to read a text file called dogYears.txt. Notice that each line of this file contains a dog's name followed by an age. The program then outputs this data to the console. The output looks like this: Tippy 2 Rex 7 Desdemona 5 1. Your task is to use the Scanner methods that will initialize the variables name1, name2, name3, age1, age2, age3 so that the execution of the three println statements below will...

  • composed the following java code to read a string from a text file but receiving compiling...

    composed the following java code to read a string from a text file but receiving compiling errors. The text file is MyNumData.txt. Included the original java script that generated the output file. Shown also in the required output results after running the java program. I can't seem to search for the string and output the results. Any assistance will be greatly appreciated. import java.io.BufferedReader; import java.io.FileReader; import java.util.ArrayList; public class Main {   public static void main(String[] args) {     System.out.print("Enter the...

  • Java code is calculating the bill wrong and not displaying currency at the end: I've highlighted...

    Java code is calculating the bill wrong and not displaying currency at the end: I've highlighted the error in the cosole Southwest Power and Light Billing Statement Please enter your name > J, P Customer name:J, P Meter reading date > 2/15/16 Meter reading date:2/15/16 Electricity used: > 225 The basic rate is:22.5 The totalBill is 225.0 Calculate another bill? (Y/N)?: The correct answer should be baseline charge: $22.50 and total bill: $22.50 The Charges are based on these: 0kw...

  • For this assignment, you will apply what you learned in analyzing for, while, and do-while loops...

    For this assignment, you will apply what you learned in analyzing for, while, and do-while loops by writing these statements yourself. The Java™ program you write should do the following: Display a pyramid of asterisks onscreen (i.e., a nested for loop) Display the integers 10 to 1 in decreasing order, one number per line (i.e., a while/do-whlie loop) Add 7 until the sum becomes greater than 157, at which point the program should display both the sum and the number...

  • Programming Project 3 See Dropbox for due date Project Outcomes: Develop a Java program that uses:...

    Programming Project 3 See Dropbox for due date Project Outcomes: Develop a Java program that uses: Exception handling File Processing(text) Regular Expressions Prep Readings: Absolute Java, chapters 1 - 9 and Regular Expression in Java Project Overview: Create a Java program that allows a user to pick a cell phone and cell phone package and shows the cost. Inthis program the design is left up to the programmer however good object oriented design is required.    Project Requirements Develop a text...

  • Modify the program that you wrote for the last exercise in a file named Baseball9.java that...

    Modify the program that you wrote for the last exercise in a file named Baseball9.java that uses the Player class stored within an array. The program should read data from the file baseball.txt for input. The Player class should once again be stored in a file named Player.java, however Baseball9.java is the only file that you need to modify for this assignment. Once all of the input data from the file is stored in the array, code and invoke a...

  • Your assignment is to write a grade book for a teacher. The teacher has a text file, which includ...

    Your assignment is to write a grade book for a teacher. The teacher has a text file, which includes student's names, and students test grades. There are four test scores for each student. Here is an example of such a file: Count: 5 Sally 78.0 84.0 79.0 86.0 Rachel 68.0 76.0 87.0 76.0 Melba 87.0 78.0 98.0 88.0 Grace 76.0 67.0 89.0 0.0 Lisa 68.0 76.0 65.0 87.0 The first line of the file will indicate the number of students...

  • For this assignment, you will use your knowledge of arrays and ArrayLists to write a Java...

    For this assignment, you will use your knowledge of arrays and ArrayLists to write a Java program that will input a file of sentences and output a report showing the tokens and shingles (defined below) for each sentence. Templates are provided below for implementing the program as two separate files: a test driver class containing the main() method, and a sentence utilities class that computes the tokens and shingles, and reports their values. The test driver template already implements accepting...

  • I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student...

    I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student {    private String name;    private double gpa;    private int idNumber;    public Student() {        this.name = "";        this.gpa = 0;        this.idNumber = 0;    }    public Student(String name, double gpa, int idNumber) {        this.name = name;        this.gpa = gpa;        this.idNumber = idNumber;    }    public Student(Student s)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT