Write a program that will take an integer and add up each of the number’s digits, count the number of digits in the number, and then average the digits. You must use a while loop and % to access each of the individual digits. Use / to reduce the number so that you can average all of the digits.
Example: num = 123 can be taken apart with tempNum = 123 % 10 (which will pull off the 3), then tempNum = tempNum / 10 (will result in 12). Do this in a loop while the number is > 0.

Sample Data :
234
10000
111
9005
84645
8547
123456789


 Be sure to include print statements that will format the output as below.

Sample Output :
234 has a digit average of 3.0

10000 has a digit average of 0.2

111 has a digit average of 1.0

9005 has a digit average of 3.5

84645 has a digit average of 5.4

8547 has a digit average of 6.0

123456789 has a digit average of 5.0

Write A Program That Will Take An Integer And Add Up Each Of The Numbers Digits, Count The Number Of

Answers

Answer 1
For count digits, you could just convert it to a String and check the length
Sum digits, convert to string then seperate each character with charAt then convert it to numbers in the return statement.
Average digits you can convert it to a String and then convert them back after taking them apart.
Answer 2
Here is my solution:

import java.lang.System.*;

public class DigiMath {   

private static int countDigits(int number)
{
       int sum = 0;
       while(number > 0)
       {
           sum ++;
           number /= 10;
       }       return sum;   
}

private static int sumDigits(int number)   
{       
      int sum = 0;       
      while(number > 0) {
           sum += number % 10;
           number /= 10;
       }
       return sum;
}
   
   public static double averageDigits( int number )
   {
       int count = countDigits(number);
       if (count > 0) {
           return (double)sumDigits(number) / (double)count;      
       } else { 
            return 0; 
       } 
   }
   
   public static void PrintDigitAverage(int number)
   {
       System.out.printf("%d has a digit average of %1.1f\n", number, averageDigits(number));
   }
   
   public static void main(String[] args) 
   {
       // Method tests (run with java -ea)
       assert countDigits(12345) == 5 : "countDigits returns wrong count";
       assert sumDigits(12345) == 15 : "sumDigits returns wrong sum";
       assert averageDigits(12345) == 3.0: "averageDigits returns wrong average";

        PrintDigitAverage(234);
        PrintDigitAverage(10000); 
        PrintDigitAverage(111); 
        PrintDigitAverage(9005); 
        PrintDigitAverage(84645); 
        PrintDigitAverage(8547); 
        PrintDigitAverage(123456789);
   }
}



Related Questions

The most common type of database is a​ __________.a. sap database
b. hierarchical database
c. relational database
d. normalized database

Answers

The relational databases are the most common type of databases. Some examples are the SQL server, Oracle, Sybase, Informix, and MySQL. This database uses structure and language consistent with first-order predicate logic. This means the data is represented by tuples and grouped into relations.

What is the ability to remove unwanted portions of an image called? cut crop copy paste

Answers

That would be known as crop

crop is the answer, Hope this helps!



Using information about natural laws, explain why some car crashes produce minor injuries and others produce catastrophic injuries.

Answers

The larger the mass and the speed, the larger the force it would produce if it crashes something. Some car crashes produce minor injuries because maybe this car is small and runs at very slow speed which would mean less force when in impact with another. However, if a big truck crashes, it is expected to produce a larger force causing catastrophic injuries.

The set of computer programs designed to coordinate the activities and functions of the hardware are called

Answers

The set of computer programs designed to coordinate the activities and functions of the hardware is called Operating Systems.

Final answer:

Operating systems are the set of computer programs responsible for managing hardware resources and providing a platform for application software to run. They ensure efficient and secure functioning of a computer by managing tasks such as CPU allocation, file storage, and access control.

Explanation:

The set of computer programs designed to coordinate the activities and functions of the hardware are called operating systems. Operating systems manage and allocate the computer's hardware resources, serving as an intermediary between applications and the physical hardware. This includes managing processes such as CPU time allocation, file storage, and access control to ensure security and efficient operation. Operating systems like Microsoft Windows and Mac OS X bundle system software with user-friendly interfaces and applications to enhance usability and performance.

These operating systems are critical for the functioning of a computer, providing a platform for running application software, and managing hardware components like the hard drive, processor, and memory. Without an operating system, users would not be able to interact with the computer in a meaningful way. The operating system ensures that different programs and users running on the computer do not interfere with each other, providing a stable environment for various computing activities.

Which port, along with a special card and cables, supports the connection of microcomputers, modems, and printers in a local area network (lan)?

Answers

The answer would be Ethernet

Ethernet permits the simultaneous connection of microprocessors, modems, and printing machines in such a local area network.

Ethernet

The traditional method of connecting is via a wired LAN or WAN. It enables devices to communicate with one another via a protocol, which should be a set of rules or even an interprocess communication phrase.

The purpose behind an Ethernet network would be that devices could effectively communicate files, knowledge, as well as information among themselves.

Thus the above response is correct.

Find out more information about Ethernet here:

https://brainly.com/question/14308966

What is one reason why business ethics are important?
a.) To enforce regular exercise among employees
b.) To profit from dishonest transactions
c.) To promote suspicious behavior in the workplace
d.) To stay within the law

Answers

d. stay within the law

I would go with the last option to stay within the law, option D.

What are the common characteristics of a bastion host?

Answers

The bastion host node is typically an influential server with better-quality security actions and custom software. It frequently hosts only a single request because it wants to be very good at whatever it does. The software is commonly modified, limited and not obtainable to the public. This host is envisioned to be the strong fact in the network to care for the system last it. Therefore, it often endures unvarying maintenance and audit. Occasionally bastion hosts are used to draw occurrences so that the basis of the attacks may be outlined. The bastion host practices and filters all inward traffic and averts malicious traffic from incoming the network, acting much like a gateway. 

Diversifying means _____. withdrawing money from a retirement account investing in a variety of types of investments to minimize risk contacting a stock broker to invest you money buying and selling a variety of stock

Answers

The answer to go in the blank would be D) buying and selling a variety of stock.

which of these should be reportable diseases to protect public health? A. Obesity B. Diabetes C.Measles D. Lung Cancer

Answers

C. Measles

Apex confirmed

Measles is a highly contagious disease that is an infection caused by the measles virus.  The symptoms develop after 10-12 days and the person can remain infected for 7-10 days.

The initial symptoms include fever, cough, running nose and as this is fast spreading disease it should be reportable to protect public health.

Hence the option C is correct.

Learn more about the should be reportable diseases to protect public health.

brainly.com/question/3801464.

!! NEED HELP FAST !!

The mathematical order of operations is used in Excel when formulas are evaluated. This order of operations states the order to be
    
  A. multiplication and division, addition and subtraction, exponentiation.

  B. addition and subtraction, multiplication and division, exponentiation.

  C. multiplication and division, exponentiation, addition and subtraction.

  D. exponentiation, multiplication and division, addition and subtraction.
 

Answers

D is the correct answer, I hope this helps you
B. addition, subtraction, multiplication, and division, exponentiation.

Read the following scenario: A project will require more people than originally estimated. Identify the possible risks to the project. A) Ideas and creativity B)Money and resources C) Policies and procedures D)Time and work ethic

Answers

Money and resources is the identification of the possible risks to the project. Hence, option B is correct.

What is Money and resources?

Money-based financial resource assets. money supply, available cash, financial resources. Money is a medium of exchange that enables people to get the necessities of life.

Bartering was a kind of exchange that existed before money was created. Money has value because, like gold and other precious metals, it often represents something valuable to the majority of people.

A resource in the economy is not money. Money cannot be used to produce anything on its own; it can only be used as a medium of exchange for economic resources. Money may appear to be an economic resource due to its ability to keep a business running, but it is only a cover for past worth and has no fundamental value.

Thus, option B is correct.

For more information about Money and resources, click here:

https://brainly.com/question/22964679

#SPJ2

Information permanently stored on a hard disk, diskette, cd-rom disk, or tape, is called ________ storage.

Answers

All of them are persistent (will survive a reboot). A CD-rom may also be immutable, if it can't be rewritten.

Match each planet with the correct characteristic.

1. closest to the sun
1
Mercury
2. retrograde rotation
Neptune
3. supports life
Venus
4. may have once had liquid water
Mars
5. most moons
Uranus
6. largest ring system
Jupiter
7. rotates on its side
Saturn
8. blue color from methane gas
3
Earth

Answers

Closest to the sun is Mercury. Largest ring system is Saturn. Blue color from methane gas is Neptune. Most moons is Jupiter, it has 67 moons. Earth supports life. Uranus rotates on its side. Mars may once have had liquid water. Venus and Uranus are a retrograde rotation. I'm almost positive about this.


Answer:

closest to the sun : MercuryRetrograde rotation:  Venus and Uranussupports : EarthMay have once had liquid water: MarsMost moons: JupiterLargest ring system: SaturnRotates on its side : UranusBlue color from methane gas : Neptune

Explanation:

There are about 8 planets including Earth that surrounds the sun and the closest to the sun is the Mercury. all the planets rotates around the sun in an eastward direction while about three planets( Venus, Uranus and Pluto) rotates in retrograde style i.e westwards around the sun

All planets have some similar characteristic in having an orbit around the sun,they have sufficient mass to overcome the force gravity been put on them by external bodies and they are also have a nearly round shape

Which of these describes a slide transition

Answers

There is no options to chose from//more info

It's B. A way to have a new slide show up with a special effect, because if you were to make a slide show then you can choose to make an effect, so its just a special effect for your slides.

The term [i]font[/i] refers to the style of lettering, but not the color.


A.True


B.False

Answers

The answer is True!It does refer to the style of lettering, and not the color of the font

what best compares and contrast visual and performing arts

Answers

Visual arts are ceramics, painting, photography, design, etc. Performing arts are more like dancing, singing, and show business. They both include many talents but visual arts is creation while performing arts is presentation. I hope that helps!

Both careers speak to an audience; however, people involved in the performing arts speak only to a live audience.

Visual arts is creation while performing arts is presentation. Both use their work to connect to their audience. However, Performing artists are always in front of a live audience. It is very rare to watch a painting being created live. A live performance would not make any sense without an audience. Visual arts give a way to express emotion, opinion, or a feeling through visual means like drawings and photography. On the other hand, performing arts expresses the mentioned through means of performance, like dance, theater, music, and more.


Statements with absolute terms are always false. Please select the best answer from the choices provided T F

Answers

I think its F but I'd try both just in case
Answer: False!!! This is the correctt answer!!!

The source code of a java program is first compiled into an intermediate language called java ____, which are platform-independent.

Answers

Answer:  bytecode

Explanation
The Java compiler converts the high-level Java code into bytecodes which can be read and executed by the JVM (the Java Virtual Machine) on each supported platform.

Answer:  bytecode

Explanation

The Java compiler converts the high-level Java code into bytecodes which can be read and executed by the JVM (the Java Virtual Machine) on each supported platform.

What is another name for a blue screen error which occurs when processes running in kernel mode encouter a problem and windows must stop the system?

Answers

Answer:

The Blue Screen of Death (BSoD) — also known as "blue screen," "stop error," or "system crash" — could happen after a critical error occurs that Windows 10 is not able to handle and resolve automatically.

Explanation:

The Blue Screen of Death (BSoD) — also known as "blue screen," "stop error," or "system crash" — could happen after a critical error occurs that Windows 10 is not able to handle and resolve automatically.

____________________ carry out all aspects of manufacturer-scheduled maintenance activities on a range of vehicle components, such as the lubrication system.

Answers

Lube Technician carry out all aspects of manufacturer-scheduled maintenance activities on a range of vehicle components, such as the lubrication system.

Jason is computer professional who has access to sensitive information. He shares this information with another organization in the same industry. Which professional code of conduct did Jason violate?

A.) diligence in service
B.) company discipline norms
C.) confidentiality of information
D.) conflict of interest

Answers

C will be your answer.

Answer:

C- CONFIDENTIALITY OF INFORMATION

Explanation:

Confidentiality of information is about privacy and respecting someone's wishes. Professionals shouldn't share sensitive details or information about their organisation or company unless that it is

absolutely necessary.

Confidentiality of information in other way means informations either in writing or orally should be confidential.

Confidentiality identifies sensitive information that, if disclosed, could damage the person or organization .

Your boss has asked you to connect three new laptops to the wireless network “wlan42.” it runs at a speed of 54 mbps only and a frequency of 2.4 ghz only. what ieee 802.11 standard should you implement when connecting the laptops to the wap?

Answers

The answer is B.Crossover Cable

Kristine has been getting many unsolicited emails from a particular address. She thinks that these emails may harm her computer. What action should she take to automatically send such emails to a separate folder?

Answers

kristine should mark the messages as spam.

Since Kristine has been getting many unwanted emails which she did not sign up for, she might have to mark all these emails’ senders as spam so that any new emails from these senders would immediately be sent to the Spam folder.

These emails can be harmless but annoying, but it can also create unknown adverse effects later on when the email is opened. Never open the links available in these type of emails because they will certainly create damage to your computer or information.

One governing factor when determining the minimum size of conduit to be used is the 
A. length of the conduit.   B. presence of water.   C. conductor fill.   D. location.

Answers

One governing factor when determining the minimum size of conduit to be used is the location. 

Answer:

Conductor fill ( C )

Explanation:

when determining the minimum size of conduit to be used for a job it is very essential to consider the conductor to be passed through it. the factors to consider in the sizing of the conduit is the size of the conductor and also the conductor count of the conductor that is to be drawn through the conduit.

The conductor Fill represents the size of the conductor to be passed through the conduit. the presence of water and location will be used to determine the type of conduit to be used and not exactly the size of the conduit.

Some personal computer manufacturers provide a hard disk configuration that connects multiple smaller disks into a single unit that acts like a single large hard disk. what is this grouping called?

Answers

In software: Logical Volume. In hardware it's usually called RAID (Redundant Array of Inexpensive Devices).

Students in the United States are guaranteed a college education. True False

Answers

False not everyone is
False, a lot of people have to pay for college in the U.S

Alicia uses a software application to store the names, email addresses, and phone numbers of her friends in alphabetical order. she uses the retrieve option to locate a number. which type of software application is she most likely using? database management software presentation software spreadsheet software word-processing software

Answers

She is in spreadsheet.

Answer:

Spreadsheet software

Explanation:

The database management software allows for the entry, retrieval and storage of data in a database. but for Alicia to successfully store the names, email addresses and phone numbers of her friends in alphabetical order she has to use A spreadsheet software to achieve that because it is less complex and since the data she is storing is simple . also since a spreadsheet software allows the retrieval of stored information hence the spreadsheet software would be the perfect tool for her to use. example of spreadsheet software includes Microsoft excel, google sheets

Zenmap's topology tab displays a __________ that shows the relative size and connection type of all discovered ip hosts.

Answers

Zenmap's topology tab displays a "Bubble Chart" that shows the relative size and connection type of all discovered IP hosts.
A kind of chart which shows three dimensional data is known as Bubble chart. It also can be seen as the variation of scatter plot where bubbles replace the data points.

Într-o curte sunt G găini și O oi. Să se determine numărul de capete și numărul de picioare din curte.

Answers

do you need this be translated?

English: I know Romanian but I think this problem can't be solved because there is not a given number of hen and sheep heads&legs.

Română: Știu Română dar nu cred că această problemă poate fi rezolvată pentru că aici nu este un număr dat de capete& picioare de găini și oi.

Which of these can be used as a smartphone with the power of a laptop?
A. Tablet
B. E-reader
C. Note Book
D. Cell Phone

Answers

I would go with A) Tablet because that's basically a bigger phone and mobile cmp combined, its not D) because that's a synonym for a smartphone and not C) because paper and pencil is not like a smartphone, and not B) because that's like reading online books.
only a,b,and d because those all have usb cords
Other Questions
There are 18 boys and 60 girls working on a community service project. they work in groups where each group has the same number of boys and the same number of girls. what is the first step to finding the greatest number of groups possible? what is the greatest number of groups possible? what is the first step in finding the solution? If the government imposes a minimum wage of $4, how many workers will be employed? The mixture you separated was mixture oof iron filings, sand, and salt. Based on your understanding of matter, is this mixture a homogeneous mixture or heterogeneous mixture? How do you know? A. Heterogeneous mixture-the parts are not uniformly mixed. B. Homogeneous mixture-the parts are uniform mixed C. Heterogenous mixture-the parts are uniformly mixed d. Homogenous mixture-the parts are not uniformly mixed one hypothesized mechanism by which antidepressant medications help to regulate mood is the suppression of ______ sleep. Historically speaking, what was the most important beverage in the caribbean, believed to have originated in barbados? Explain how horace mann's work reflects ongoing impact of puritan culture and beliefs What does the author most likely mean by "memory is an abstract painting"? a. We remember events in vague and indistinct ways. b. We usually respond to art that shows places we remember. c. We tend to remember artwork we saw when we were young.d. We are more likely to remember colorful people and places. the expression 12x+15x-11x can be combined because of which property A. commutative property of additionB. distributive propertyC. additive inverse propertyD. multiplicative property (1) Shark species come in all shapes and sizes. (2) The smallest, the spined pygmy shark, is only 7 inches long. (3) The largest is the whale shark, which can grow to 50 feet long. (4) Most sharks are about the same size as an adult person. (5) Many are shaped like torpedos, so they can cut easily through the water. (6) Others have flat bodies, so they can glide along the ocean bottom. (7) Scientists know sharks have existed for a long time because 350-million-year-old shark's teeth have been found. (8) These teeth are extremely hard and fossilize well. (9) As for habitat, sharks live in all the oceans of the world. (10) They also make their homes in some lakes and rivers. 5 In the paragraphs above, which sentence could best be added before sentence 5? (5) Many are shaped like torpedos, so they can cut easily through the water. A. Sharks gulp down their food without chewing it. B. Scientists have proven that sharks are intelligent. C. Sharks come in a wide range of shapes. D. The hammerhead shark has a very wide head. Which category in Maslow's hierarchy includes basic survival needs such as air, food, water, and shelter? A. Physiological needs B. Social needs C. Safety needs D. Self Actualization Globalization concerns many workers because ________. 24=62(2n+3) What value on n makes the equation true? Irene sues mark for defamation. during the lawsuit, irene wants to obtain mark's posts on his social media. irene will: If CDEF MNPQ, then EF _____.PQ.QM.MN.NQ What is a term that identifies the group of people a person may be attracted to?? Which geographical characteristic most encourages an increase in the population density of a region?A. high elevationB. Rugged terrainC. A lack of wildlifeD. Available drinking water Alicia wants to cover a section of her wall that is 2 feet wide and 12 feet long with mirrors.Each mirror tile is 2 feet wide and 1.5 feet long.How many mirror tiles does she need to cover that section? How would the seasons change if the earth were tilted at 90 degrees instead of 23.5? Which of the following statements most accurately differentiates potential and kinetic energy? A. Any object that has motion has kinetic energy, while any object not in motion but with the potential to do work has potential energy. B. Gravitational potential energy is a form of mechanical energy, while kinetic energy is not. C. Any object that has motion has potential energy, while any object not in motion but with the potential to do work has kinetic energy. D. Kinetic energy is a form of mechanical energy, while gravitational potential energy is not. Rose leaves her apartment to take her dog for a walk. She goes 3 blocks due south, 8 blocks due east, 5 blocks due north, and 8 blocks due west. At this point, where is Rose in relation to her apartment? Steam Workshop Downloader