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
sergejj [24]
2 years ago
6

Write a program that inputs a five-digit integer, spearates the integer into its digits and prints them seperated by three space

s each. [Hint: Use the ineger division and remainder operators.]
Computers and Technology
1 answer:
FromTheMoon [43]2 years ago
8 0
<h2>Explanation:</h2>

The source code and a sample output have been attached to this response.

The code has been written in Java and it contains comments explaining important parts of the code.

A few things that are worth noting are in the for loop used in the code;

<em><u>The loop goes from i = 4 to i = 0</u></em>

<em>When i = 4;</em>

=> (int) Math.pow(10, i) = (int) Math.pow(10, 4) = 10000

Then the <em>fiveDigit</em> is divided by 10000. Since this is an integer division, the first digit of the 5-digit number will be stored in <em>digit </em>which is then printed to the console.

Next, the remainder is calculated and stored in <em>fiveDigit</em>

<em>When i = 3;</em>

=> (int) Math.pow(10, i) = (int) Math.pow(10, 3) = 1000

Then the <em>fiveDigit</em> (which is the remainder when i = 4) is divided by 1000. Since this is an integer division, the second digit of the 5-digit number will be stored in <em>digit </em>which is then printed to the console.

Next, the remainder is calculated and stored in <em>fiveDigit</em>

<em>When i = 2;</em>

(int) Math.pow(10, i) = (int) Math.pow(10, 2) = 100

Then the <em>fiveDigit</em> (which is the remainder when i = 3) is divided by 100. Since this is an integer division, the third digit of the 5-digit number will be stored in <em>digit </em>which is then printed to the console.

Next, the remainder is calculated and stored in <em>fiveDigit</em>

<em>When i = 1;</em>

(int) Math.pow(10, i) = (int) Math.pow(10, 1) = 10

Then the <em>fiveDigit</em> (which is the remainder when i = 2) is divided by 100. Since this is an integer division, the fourth digit of the 5-digit number will be stored in <em>digit </em>which is then printed to the console.

Next, the remainder is calculated and stored in <em>fiveDigit</em>

<em>When i = 0;</em>

(int) Math.pow(10, i) = (int) Math.pow(10, 0) = 1

Then the <em>fiveDigit</em> (which is the remainder when i = 1) is divided by 1000. Since this is an integer division, the fifth digit of the 5-digit number will be stored in <em>digit </em>which is then printed to the console.

Next, the remainder is calculated and stored in <em>fiveDigit </em>and then the program ends.

You might be interested in
To maintain her audience's confidence in her, what should kiara not do while delivering her presentation?
IrinaVladis [17]
Use filler words like ummmm, like, so, kinda, or such. Faltering on her words, forgetting things, or not saying things with confidence wouldn't help either. Also, do not loose eye contact with the people even if you only occasionally look up, it makes you look nervous and like you don't know what you're talking about.
7 0
3 years ago
You are working on a ticketing system. A ticket costs $10. The office is running a discount campaign: each group of 5 people is
cupoosta [38]

Answer:

Explanation:

The following program is written in Java. It takes 5 inputs of int values for the ages of each member in the group. Then it loops through all of the ages and chooses the youngest age. Finally, it applies that age as a discount to the final price which would be $50, outputting the final discounted price. The output for the test case provided can be seen in the attached picture below in red.

import java.util.Scanner;

class Brainly

{

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       int[] person = new int[5];

       System.out.println("Enter age of individual 1: ");

       person[0] = in.nextInt();

       System.out.println("Enter age of individual 2: ");

       person[1] = in.nextInt();

       System.out.println("Enter age of individual 3: ");

       person[2] = in.nextInt();

       System.out.println("Enter age of individual 4: ");

       person[3] = in.nextInt();

       System.out.println("Enter age of individual 5: ");

       person[4] = in.nextInt();

       int youngest = person[0];

       for (int x = 0; x < person.length; x++) {

           if (person[x] < youngest) {

               youngest = person[x];

           }

       }

       double discount = 1 - (((double)youngest) / 100);

       double output = 50 * discount;

       System.out.println("Total Price: " + output + " the youngest is " + youngest);

   }

}

8 0
2 years ago
SummaryIn this lab, you complete a partially written C++ program that includes a function named multiplyNumbers() that multiplie
Maru [420]

Answer:

Declare the method prototype using:

void multiplyNumbers(int x, int y,int &product);

Call the function using:

multiplyNumbers(num1, num2,product);

Lastly, the method is as follows:

void multiplyNumbers (int x, int y,int &product) {

  product = x * y;

  return; }

Explanation:

Declare the method prototype using

void multiplyNumbers(int x, int y,int &product);

Call the function using

multiplyNumbers(num1, num2,product);

The method is as follows; the & written in front of product implies that product is passed by reference

void multiplyNumbers (int x, int y,int &product) {

This calculate the product

  product = x * y;

This returns nothing

  return; }

<em>See attachment for complete program</em>

Download cpp
5 0
3 years ago
You write a short story, but you want to make sure your work is protected before you post it online. What should you do to help
Mars2501 [29]
Make sure you but no copyright, author, and date of publication, that may help.
8 0
3 years ago
An independent penetration testing company is invited to test a company's legacy banking application developed for Android phone
LenaWriter [7]

In the case above, the company can prevent this from happening in the public Internet through the Use certificate pinning.

<h3>Should a person use certificate pinning?</h3>

Mobile applications are known to be one that often make use of   certificate or also public key pinning so that they can be able to make sure that communications are secure.

Hence it is one that  is often implemented if  the developer of the application is said to be require to validate the remote host's identity or if operating in a harsh environment.

Hence, Certificate pinning hinders which certificates are considered valid for a any kind of website,  and as such, In the case above, the company can prevent this from happening in the public Internet through the Use certificate pinning.

Learn more about certificate from

brainly.com/question/1874937

#SPJ1

4 0
1 year ago
Other questions:
  • When ordering a new​ zagflatz, customers must choose the style of three major​ components, each of which has about ten variation
    6·1 answer
  • One of the most famous ___ licenses is gpl, which ensures that a particular program remains free to distribute and allows its co
    10·1 answer
  • True / False<br> 1. A byte is a standardized unit of measure that is always 8-bits.
    7·1 answer
  • What movie would be greatly improved if it was made into a musical?
    6·1 answer
  • Many languages do not use the characters of U.S. English. Suppose you wanted to be able to
    15·1 answer
  • Sometimes a database can contain "bad data," meaning incomplete, incorrect, inaccurate, or irrelevant records, which can be corr
    7·1 answer
  • Solve this for brainlest​
    10·1 answer
  • true or false You are able to change the formatting of a table after it is inserted into a placeholder.
    6·1 answer
  • Your program will be used by many departments at the university. Your comments will be important to their IT people. What would
    13·1 answer
  • 5. Nadia wants to calculate the total interest, which is the total amount of the payments minus the loan amount. In cell F6, ent
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!