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
Novosadov [1.4K]
4 years ago
6

This assignment will give you more experience on the use of loops In this project, we are going to compute the number of times a

given digit D appears in a given number N. For example, the number of times 5 appears in 1550 is 2. The number of times 0 appears in 1550 is 1. The number of times 3 appears in 155 is 0. Etc.
Engineering
1 answer:
musickatia [10]4 years ago
3 0

Answer:

import java.io.BufferedReader;

import java.io.File;

import java.io.FileReader;

import java.io.IOException;

import java.util.Scanner;

import java.util.StringTokenizer;

public class Tester {

public static void main(String[] args) throws IOException {

Scanner in=new Scanner(System.in);

   System.out.println("Enter a Number =======>");

   long N ;

   while (!in.hasNextLong()) {

       System.out.println("That's not a number!");

       in.next();

   }

   N=in.nextLong();

   System.out.println("Number Entered is =======>"+N);

   System.out.println("Enter a Digit =======>");

   int D;

   while (!in.hasNextLong()) {

       System.out.println("That's not a number!");

       in.next();

   }

   D=in.nextInt();

   System.out.println("Digit Entered is =======> "+ D);

   long que=N;

   int rem;

   int count=0;

   while(true){

       long temp;

       temp = (long)que/10;

       

       rem = (int) (que % 10);

       System.out.println(temp+" "+ que+" "+rem);

       if(rem==D) count++;

       que=temp;

       if(que==0) break;

       

   }

   System.out.println("The number of "+ D+"'s in "+ N + " is "+ count );;

   

   

}

}

Explanation:

  • Divide the que variable by 10 and assign its result to the temp variable.
  • Calculate the remainder.
  • Increment the count if the remainder is equal to the value of D variable and assign the value of que to temp variable.
You might be interested in
The iron-blade plow allowed humans to increase food production during<br> what age?
lilavasa [31]

Answer:

The Iron Age

Explanation:

4 0
3 years ago
The phrase "positive to positive, negative to ground" is correct when jump starting a car.
Artist 52 [7]

The correct answer is A; True.

Further Explanation:

This is a correct phrase that is important to learn when owning any type of vehicle. When a car battery is dead, it can usually be jump started by using another cars battery or a portable battery charger. It is extremely important to put the positive battery cable on the positive battery post. Then the negative cable will be placed on the negative car battery post and the negative ground wire can be anywhere on the car except on the battery.

The car needs to be connected properly for a few minutes before trying to start the car. This helps the car battery to get enough "juice" to start. If the battery cables are placed wrong this can cause sparks to come out of the cables/battery and cause bodily harm.

Learn more about car batteries at brainly.com/question/7734062

#LearnwithBrainly

7 0
3 years ago
A boy weighing 108-lb starts from rest at the bottom A of a 6-percent incline and increases his speed at a constant rate to 7 mi
baherus [9]

Answer:

88.18 W

Explanation:

The weight of the boy is given as 108 lb

Change to kg =108*0.453592= 48.988 kg = 49 kg

The slope is given as 6% , change it to degrees as

6/100 =0.06

tan⁻(0.06)= 3.43°

The boy is travelling at a constant speed up the slope = 7mi/hr

Change 7 mi/h to m/s

7*0.44704 =3.13 m/s

Formula for power P=F*v where

P=power output

F=force

v=velocity

Finding force

F=m*g*sin 3.43°

F=49*9.81*sin 3.43° =28.17

Finding the power out

P=28.17*3.13 =88.18 W

4 0
3 years ago
Define and discuss the difference between micronutrients and macronutrients. Also, discuss their importance in the body at rest
almond37 [142]

Answer:

Macronutrients are simply nutrients the body needs in a very high amount e.g Carbohydrate.

MicroNutrients are simply nutrients the body needs but in little amount e.g  Minerals.

Explanation:

So for further breakdown:

What are nutrients? Nutrients are essential elements that nourish the body in different capacities. We as humans get most of out nutrients from the food and water we ingest.

Now about Macro Nutrients: From the prefix "Macro" which means large, we can infer that macro nutrients are elements need by the body for the fundamental processes of the body, deficiency in this nutrients are very easy to spot. Examples are: Carbohydrates, Protein, Fats amd Water.

Micro Nutrients: In relation to macro nutrients this are elements that the body needs but are not needed in Large quantities. They mostly work like supporting nutrients. Most chemical activities like reaction that occur in the body are a function of micro nutrients. Defiencies in micrp nutrients may take some time to spot e.g Minerals and Vitamins

In regards to exercise: Macro nutrients are the essential ones here since they are the ones that generate energy. PS: micro nutrients dont generate energy.

In regards to rest: Both the Macro and Micro Nutrients are essentail for the overall well being of the body.

5 0
3 years ago
Consider two different versions of algorithm for finding gcd of two numbers (as given below), Estimate how many times faster it
juin [17]

Answer:

Explanation:

Step 1:

a) The formula for compute greatest advisor is

     gcd(m,n) = gcd (n,m mod n)

the gcd(31415,14142) by applying Euclid's algorithm is

    gcd(31,415,14,142) =gcd(14,142,3,131)

                                  =gcd=(3,131, 1,618)

                                   =gcd(1,618, 1,513)

                                   =gcd(1,513, 105)

                                   =gcd(105, 43)

                                    =gcd(43, 19)

                                     =gcd(19, 5)

                                      =gcd(5, 4)

                                      =gcd(4, 1)

                                      =gcd(1, 0)

                                      =1

STEP 2

b)  The number of comparison of given input with the algorithm based on  checking consecutive integers and Euclid's algorithm is

     The number of division using Euclid's algorithm =10 from part (a)

      The consecutive integer checking algorithm:

      The number of iterations =14,142 and 1 or 2 division of iteration.

        14,142 ∠= number of division∠ = 2*14,142

         Euclid's algorithm is faster by at least 14,142/10 =1400 times

          At most 2*14,142/10 =2800 times.

5 0
3 years ago
Other questions:
  • The mechanical properties of a metal may be improved by incorporating fine particles of its oxide. Given that the moduli of elas
    11·1 answer
  • What does CADCAM stand for ?
    10·2 answers
  • Explain why the scenario below fails to illustrate an understanding of the importance of metrology. Situation: Natalie is a cali
    6·1 answer
  • 10. When an adhesion bond is made by melting a filler metal and allowing it to spread into the pores of the
    7·1 answer
  • A field sample of an unconfined aquifer is packed in a test cylinder. The length and diameter of the cylinder are 50 cm and 6 cm
    9·1 answer
  • What forced induction device is more efficient?
    8·2 answers
  • How can you drop two eggs the feweHow can you drop two eggs the fewest amount of times, without them breaking? ...st amount of t
    13·2 answers
  • The annual average of solar photovoltaic energy in Phoenix is 6,720
    8·1 answer
  • Component of earthing and reasons why each material is being used<br><br>​
    5·1 answer
  • Binary classification algorithm
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!