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
A manometer containing a fluid with a density of 60 lbm/ft3 is attached to a tank filled with air. If the gage pressure of the a
8090 [49]

Answer:

The fluid level difference in the manometer arm = 22.56 ft.

Explanation:

Assumption: The fluid in the manometer is incompressible, that is, its density is constant.

The fluid level difference between the two arms of the manometer gives the gage pressure of the air in the tank.

And P(gage) = ρgh

ρ = density of the manometer fluid = 60 lbm/ft³

g = acceleration due to gravity = 32.2 ft/s²

ρg = 60 × 32.2 = 1932 lbm/ft²s²

ρg = 1932 lbm/ft²s² × 1lbf.s²/32.2lbm.ft = 60 lbf/ft³

h = fluid level difference between the two arms of the manometer = ?

P(gage) = 9.4 psig = 9.4 × 144 = 1353.6 lbf/ft²

1353.6 = ρg × h = 60 lbf/ft³ × h

h = 1353.6/60 = 22.56 ft

A diagrammatic representation of this setup is presented in the attached image.

Hope this helps!

5 0
3 years ago
Which of following are coding languages used in controlling a robot? *
Bess [88]

Answer:

C/C++

Explanation:

C/C++

7 0
2 years ago
A tool chest has 950 N weight that acts through the midpoint of the chest. The chest is supported by feet at A and rollers at B.
Mazyrski [523]

Answer:

P > 142.5 N  (→)

the motion sliding

Explanation:

Given

W = 959 N

μs = 0.3

If we apply

∑ Fy = 0 (+↑)

Ay + By = W

If  Ay = By

2*By = W

By = W / 2

By = 950 N / 2

By = 475 N (↑)

Then  we can get F (the force of friction) as follows

F = μs*N = μs*By

F = 0.3*475 N

F = 142.5 N (←)

we can apply

P - F  > 0

P  > 142.5 N (→)

the motion sliding

6 0
3 years ago
wo companies, Ajax Co. and Boho Inc., were negotiating a merger. In the course of the negotiations, an Ajax representative told
boyakko [2]

Answer:

Yes

Explanation:

If the Ajax representative fails to correct the previous statement this can cause misrepresentation.

4 0
2 years ago
How much force is required if the ramp is 15 ft long
lord [1]

Answer:

do yah stiil need help

Explanation:

6 0
2 years ago
Other questions:
  • A storm sewer is carrying snow melt containing 1.2 g/L of sodium chloride into a small stream. The stream has a naturally occurr
    14·1 answer
  • PLZ HURRY IM ON A TIMER
    6·1 answer
  • A horse on the merry-go-round moves according to the equations r = 8 ft, u = (0.6t) rad, and z = (1.5 sin u) ft, where t is in s
    5·1 answer
  • The status of which of these determines the sequence in which output devices, such as solenoid values and motor contactors, are
    15·1 answer
  • 1. What are the usual symptoms of brake issues?​
    15·1 answer
  • A round bar of chromium steel, (ρ= 7833 kg/m, k =48.9 W/m-K, c =0.115 KJ/kg-K, α=3.91 ×10^-6 m^2/s) emerges from a heat treatmen
    14·1 answer
  • Which source would be the best to base a hypothesis upon
    9·1 answer
  • If noise levels are high enough that you have to raise
    7·1 answer
  • Explain what the engineering team should advise in the following scenario.
    7·1 answer
  • Global climate and weather patterns are driven by differences in the amount of heat energy in different areas of the earth. Whic
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!