1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ella [17]
4 years ago
15

Write code statements to create a DecimalFormat object that will round a formatted value to four decimal places. Then write a st

atement that uses that object to print the value of result, properly formatted.
Computers and Technology
1 answer:
KonstantinChe [14]4 years ago
3 0

Answer:

Following is the code in Java Language :

DecimalFormat form1= new DecimalFormat ("0.####");  // create an instance of                                                                                            .                                                                                            //DecimalFormat

System.out.println (form1.format(res)); // display the value in proper format

Explanation:

Following are the description of the program

  • Firstly we create the instance of DecimalFormat i.e  "form1"  that will round a formatted value to four decimal places. To create an instance or object of the class we can use a new keyword.
  • Finally, we print the format by using the format method.In the format method, we pass the variable "res".The System.out.println() is used to display the value of the format.
You might be interested in
The factorial of an integer N is the product of the integers between 1 and N, inclusive. Write a while loop that computes the fa
alexdok [17]

the function and loop will be

def factorial(x):

   total = 1

   if x != 1 and x != 0:

       for i in range(x,1,-1):

           total *= i

   return total

3 0
4 years ago
Write an Email of your Friend Asking Him Help i​
lyudmila [28]

Answer:

Explanation:

7

3 0
3 years ago
Read 2 more answers
Your company has just purchased an iSCSI storage array. You have installed a new iSCSI device onto your Ethernet network and you
Mars2501 [29]

Answer:

D) ISCSI Initiator

Explanation:

5 0
4 years ago
Which of the following correctly revises the passive voice of the sentence above to active voice?
muminat

There is no question on the passive voice, therefore I cannot change it to an active voice.

I hope this helped!

6 0
3 years ago
java methods Write a program whose input is a character and a string, and whose output indicates the number of times the charact
AfilCa [17]

Answer:

Here is the JAVA program:

import java.util.Scanner; // for taking input from user

//class to count number of times a character appears in the string

public class CharacterCounter

//method which returns number of times a character appear in string

{ public static int CountCharacter(String userString, char character)

   {  

       int counter = 0;   //stores the no of times character appears in string

for (int i=0; i<userString.length(); i++) //loop moves through entire string

       { // if character matches the character in the string

           if (userString.charAt(i) == character)

           counter++;  // adds one to the character counter variable

       }  

       return counter;     } // returns no of time character is found in string

public static void main(String[] args) {

    Scanner scanner = new Scanner(System. in);//takes input from user

    String string;

    char character;

       System.out.println("Enter a string"); //prompts user to enter a string

       string = scanner.nextLine(); //scans the input string

       System.out.println("Enter a character");

       // prompts user to enter character

       character = scanner.next().charAt(0); //scans and reads the character

       System.out.println("number of times character "+character + " appears in the string " + string +": " + CountCharacter(string, character));  }  }

// calls CountCharacter method to output no of times a character appears in the input string

Explanation:

The method CountCharacter() has a loop in which the variable i works as an index which moves through each character of the string and if the character of the string in i matches the character which is to be found in the string then the value of counter variable increments by 1. This means that counter variable keeps counting the number of time the character appears in the string. The loop breaks when value of i exceeds the length of the string which means that the i reaches the end of the string and has searched the entire string for the specified character. In the end the count variable returns the number of time character appeared in the string. The main() function takes as input from the user, a string and a character to be searched for in the string. It then calls CountCharacter() function to find the number of times that input character appears in the input string and displays it on the output screen.

The program along with its output is attached as a screenshot.

5 0
4 years ago
Other questions:
  • The strength of the electromagnetic waves being radiated from an antenna is referred to as gain, which involves a measurement of
    9·1 answer
  • What is the acronym that helps you remember the order of math operations?
    9·2 answers
  • Internet Security: How can you work securely on the internet? What actions should be avoided and what are the pitfalls?
    9·1 answer
  • I will give brainliest !!
    15·1 answer
  • with the current computer development, explain 5th areas where computer is applied for the social economic dwvelopment in societ
    11·1 answer
  • Give the an example of the following .<br>a.)typing software<br>​
    10·2 answers
  • In general, the outside _____ and sleeves of the isolation gown and outside front of the goggles, mask, respirator and face shie
    6·2 answers
  • We can save our data peremently on a
    7·2 answers
  • What do you think that private information like passwords, PIN numbers, will be guarded or shared with the public? Why?​
    13·1 answer
  • 1-List some applications appropriate for each of the display technologies: raster refresh systems,plasma panels, and LCDs.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!