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
Andrej [43]
2 years ago
15

Create a Boolean function odd_number_digits(n) that returns True when a positive integer has an odd number of digits. (You may a

ssume that I will not use a number greater than 1,000,000.) Then, use it to make a
function sum_odd_digits(n) that sums all the numbers from 0 to n that have an odd number of digits.

Computers and Technology
1 answer:
Snowcat [4.5K]2 years ago
8 0

Answer:

Following are the code to this question:

import java.util.*;//import package for user input

public class Main//defining class main

{

   public static boolean odd_number_digits(int n)//defining boolean method odd_number_digits

   {

       if(n>0 && n%2!=0)//defining if block that check value is positive and odd number

       {

       return true;//return value true

       }

       else//defining else block

       {

           return false;//return false value

       }

   }

   public static void  sum_odd_digits(int n)//defining a method sum_odd_digits

   {

       int sum=0,i;//defining integer variable

       for(i=0;i<=n;i++)//defining for loop

       {

           if(i%2!=0)//defining if block for odd number

           {

               sum=sum+i;//add odd number

           }

       }

      System.out.print(sum);//use print method to print sum value

   }

public static void main(String[] args) //defining main method

   {

       Scanner ox=new Scanner(System.in);//creating Scanner object

       int n= ox.nextInt();//defining integer variable for input value

       System.out.print(odd_number_digits(n)+ "\n");//use print method to call method

       System.out.println("Sum of odd numbers: ");//print message

       sum_odd_digits(n);//calling method

   }

}

Output:

please find the attachment.

Explanation:

In the above code, two methods "odd_number_digits and sum_odd_digits" are defined in which the first method return type is boolean because it will true or false value, and the second method returns the sum of odd numbers.

In the "odd_number_digits" method,  an integer variable passes as an argument and inside the method, if block is used that check value is a positive and odd number then it will return a true value.

In the "sum_odd_digits" method, it accepts an integer parameter "n", and define integer variable "sum" inside the method, which uses the for loop, inside the loop if block is used that counts odd numbers and adds its in sum and print its value.

You might be interested in
By Carl Sandburg
Eva8 [605]
The answer is 1 because the poet uses personification.
6 0
3 years ago
When copper wires are bundled together, they are susceptible to ____________, a form of interference where the signals leak out
maksim [4K]

Answer:

crosstalk

Explanation:

6 0
1 year ago
If your pulse is higher than your Target Heart Rate during exercise, what should you do?
vodomira [7]
If your heart rate exceeds 185 beats per minute during exercise, it is dangerous for you. Your target heart rate zone is the range of heart rate that you should aim for if you want to become physically fit. It is calculated as 60 to 80 percent of your maximum heart rate.
8 0
2 years ago
Read 2 more answers
In a natural-language processing (NLP) system, the__________activity involves using the computer to read large amounts of text a
OleMash [197]

Answer:

Analysis is the right suitable word to complete the sentence

Explanation:

It is because, Analysis is a concept, which means to judge any subjects and brings some original concept which is needed to take from the subjects.

Here in the above question the paragraph states about the summarize points taken from a large amount of data and analysis also mean the same and analysis is also the activity used in NLP for the same as above discussed.

7 0
2 years ago
__ means having a current knowledge and understanding of computers, mobile devices, the web, and related technologies.
Brrunno [24]

Answer:

Digital literacy

Explanation:

Digital Literacy means having a current knowledge and understanding of computers, mobile devices, the web, and related technologies.

Brainliest plz

8 0
3 years ago
Other questions:
  • Typically, a dvd has how many times more capacity than a cd?
    5·1 answer
  • 4. The same data source can be used multiple times in creating mail-merge documents.
    7·1 answer
  • In the file MajorSalary, data have been collected from 111 College of Business graduates on their monthly starting salaries. The
    15·1 answer
  • 4+4 act quick for brainliest
    10·2 answers
  • Which of the following will you select as X in the following series of clicks to lay the title over a chart: Chart Title box &gt
    14·1 answer
  • The Business Information Building Block feature is available in the _____ grouping on the Insert tab.
    13·1 answer
  • State all the generations of computers.
    10·2 answers
  • Allows a user to control the<br>volume of the computer​
    8·1 answer
  • Someone gave me flashcards on a keychan. I have to memorize them and then give them back. Can I back them up to my PC by creatin
    5·1 answer
  • What is the difference between PowerPoint and Outlook?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!