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
An ideal gas turbine operates using air coming at 355C and 350 kPa at a flow rate of 2.0 kg/s. Find the rate work output
GuDViN [60]

Answer:

The rate of work output = -396.17 kJ/s

Explanation:

Here we have the given parameters

Initial temperature, T₁ = 355°C = 628.15 K

Initial pressure, P₁ = 350 kPa

h₁ = 763.088 kJ/kg

s₁ = 4.287 kJ/(kg·K)

Assuming an isentropic system, from tables, we look for the saturation temperature of saturated air at 4.287 kJ/(kg·K) which is approximately

h₂ = 79.572 kJ/kg

The saturation temperature at the given

T₂ = 79°C

The rate of work output \dot W = \dot m×c_p×(T₂ - T₁)

Where;

c_p = The specific heat of air at constant pressure = 0.7177 kJ/(kg·K)

\dot m =  The mass flow rate = 2.0 kg/s

Substituting the values, we have;

\dot W = 2.0 × 0.7177 × (79 - 355) = -396.17 kJ/s

\dot W = -396.17 kJ/s

7 0
4 years ago
You receive the bill for servicing your diesel engined car. As a good engineer you immediately notice that one of the items on b
vichka [17]

Answer:

b. spark plugs

Explanation:

Diesel engines are characterized in that the mechanism that activates the explosion of fuel is high pressures, so when the piston reaches the top of the cylinder, the pressure of the air-diessel mixture is so high that it causes the explosion, this It is what generates the power in a diesel engine.

3 0
3 years ago
Impedance is defined as the total opposition to current in an AC circuit. Question 17 options: True False
ArbitrLikvidat [17]

Answer: True

Explanation:

The total opposition to current flow in an AC circuit is known as Impedance.

8 0
2 years ago
What does carbon addition to iron do, what does it produce, how does it change properties, what are its reflections? Describe in
NISA [10]

Answer:

Demire karbon ilavesi ne yapar, ne değiştirir, özellikleri nasıl değiştirir, yansımaları nelerdir? Grafiklerde kullanarak detaylı olarak açıklayın. HMK brainly.com/app/profile/7139574 takip et!!!!  

8 0
4 years ago
A single-degree-of-freedom mass-spring-damper system is observed during its free vibration and the displacement amplitude decays
AleksandrR [38]

Answer:

Logarithmic decrement is equal to 0.182

Explanation:

given,

amplitude decay = 9 dB          

number of cycles = 12 cycles        

mass of the system = 7 kg        

spring stiffness = 3000 N/m            

logarithmic decrement = ?                  

now,                                                      

logarithmic decreament = ln\ D^{\frac{1}{n}}

                                        = ln\ 9^{\frac{1}{12}}

                                        =ln (1.2)

                                        = 0.182

Hence, Logarithmic decrement is equal to 0.182

5 0
4 years ago
Other questions:
  • A room is cooled by circulating chilled water through a heat exchanger located in the room. The air is circulated through the he
    15·1 answer
  • You are driving on a roadway with multiple lanes of travel in the same direction, and are approaching an emergency vehicle parke
    11·1 answer
  • A series circuit consists of a 0.440-H inductor, a 380.0-Ω resistor, a 5.70-μF capacitor, and an ac voltage source of amplitude
    10·1 answer
  • How did the universe begin
    11·1 answer
  • A 78-percent efficient 12-hp pump is pumping water from a lake to a nearby pool at a rate of 1.5 ft3/s through a constant-diamet
    10·1 answer
  • If noise levels are high enough that you have to raise
    7·1 answer
  • Which of the following actions by farmers contributes to desertification?
    6·1 answer
  • Which of the following would NOT be an enforcement responsibility of a local police officer?
    15·1 answer
  • Es un principio de la distribución en plantas.
    15·1 answer
  • What’s the answer???
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!