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]
3 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]3 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
At an axial load of 22 kN, a 15-mm-thick × 40-mm-wide polyimide polymer bar elongates 4.1 mm while the bar width contracts 0.15
Alenkasestr [34]

Answer:

The Poisson's Ratio of the bar is 0.247

Explanation:

The Poisson's ratio is got by using the formula

Lateral strain / longitudinal strain

Lateral strain = elongation / original width (since we are given the change in width as a result of compession)

Lateral strain = 0.15mm / 40 mm =0.00375

Please note that strain is a dimensionless quantity, hence it has no unit.

The Longitudinal strain is the ratio of the elongation to the original length in the longitudinal direction.

Longitudinal strain = 4.1 mm / 270 mm = 0.015185

Hence, the Poisson's ratio of the bar is 0.00375/0.015185 = 0.247

The Poisson's Ratio of the bar is 0.247

Please note also that this quantity also does not have a dimension

3 0
3 years ago
What are two factors that determine the thermal energy of a substance
Sav [38]
Mass and chemical composition
6 0
3 years ago
__________ affect(s) the amount of air conditioning required.
Grace [21]

Answer:

Option D

All the above

Explanation:

Depending with the number of occupants in a building, the number of air conditioners required can either be increased or reduced. For instance, if the building is to be a classroom of over 50 students, 1 air-conditioner can't serve effectively. Similarly, the activity of occupants also dictate the amount of air conditioners required since if it's a gym room where occupants exercise often then the air conditioners required is different from if the room was to serve as a  lounge. The appliances that also operate in a room require that air conditioners be installed as per the heat that may be generated by the appliances.

5 0
3 years ago
Which tool ensures that a fastener has the proper amount of tightness
Sidana [21]

A torque wrench tool is a tool that ensures that a fastener has the proper amount of tightness.

<h3>What is the torque wrench used for?</h3>

The torque wrench tool is used to ensure screws and bolts are properly tightened. When performing home repairs and maintenance of equipment it is quite important that a torque wrench is used in other to prevent a scenario where a fastener (screws and bolts) does not become loose leading to equipment failure or damage. Because of its many advantages, this tool is often found in the possession of construction workers.

You can learn more about the benefits of a torque wrench tool here

brainly.com/question/15075481

#SPJ1

7 0
2 years ago
A metal shear can be used to cut flat stock , round stock , channel iron and which of the following?
Charra [1.4K]

Answer:

Angle Iron

Explanation:

Mark brainliest please.

3 0
2 years ago
Other questions:
  • Explain the two advantages and the two disadvantages of fission as an energy source.
    12·1 answer
  • A turbine produces shaft power from a gas that enters the turbine with a (static) temperature of 628 K, a velocity of 143 m/s an
    7·1 answer
  • Is a jeep cherokee faster than a bmw 325i
    12·2 answers
  • A furnace wall consisting of 0.25 m of fire clay brick, 0.20 m of kaolin, and a 0.10‐m outer layer of masonry brick is exposed t
    8·1 answer
  • According to fire regulations in a town, the pressure drop in a commercial steel, horizontal pipe must not exceed 2.0 psi per 25
    5·1 answer
  • Suppose that the voltage is reduced by 10 percent (to 90 VV). By what percentage is the power reduced? Assume that the resistanc
    10·1 answer
  • A motor vehicle has a mass of 1200kg and the road wheels have a radius of 360mm. The engine rotating parts have a moment of iner
    5·1 answer
  • Identify renewable energy sources you will propose. Explain the key elements to your solution and the basic technical principles
    5·1 answer
  • An ideal gas is contained in a closed assembly with an initial pressure and temperature of
    14·1 answer
  • Water flow enters a pipe at a velocity of 1m/s. The pipe inlet is 10cm. The pipe outlet is 6cm. 1. Determine the velocity of the
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!