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 wastewater plant discharges a treated effluent (w) with a flow rate of 1.1 m^3/s, 50 mg/L BOD5 and 2 mg/L DO into a river (s)
4vir4ik [10]

A wastewater plant discharges a treated effluent (w) with a flow rate of 1.1 m^3/s, 50 mg/L BOD5 and 2 mg/L DO into a river (s) with a flow rate of 8.7 m^3/s, 6 mg/L BOD5 and 8.3 mg/L DO. Both streams are at 20°C. After mixing, the river is 3 meters deep and flowing at a velocity of 0.50 m/s. DOsat for this river is 9.0 mg/L. The deoxygenation constant is kd= 0.20 d^-1 and The reaction rate constant k at 20 °C is 0.27 d^-1.

The answer therefore would be the number 0.27 divided by two and then square while getting the square you would make it a binomial.

I wont give the answer but the steps

Your Welcome

8 0
3 years ago
9. A vehicle is having routine maintenance performed.
dexar [7]

Answer: b

Explanation:

8 0
3 years ago
A body weighs 50 N and hangs from a spring with spring constant of 50 N/m. A dashpot is attached to the body. If the body is rai
lbvjy [14]

Answer:

a) 3.607 m

b) 1.5963 m

Explanation:

See that attached pictures for explanation.

3 0
2 years ago
What is the focus of 7th grade civics
Jobisdone [24]
C. seems like the best answer. i may be wrong so don’t quote me on that
7 0
3 years ago
Read 2 more answers
A submarine submerges by admitting seawater (S = 1.03) into its ballast tanks. The amount of water admitted is controlled by air
ser-zykov [4K]

Answer:

Explanation:

Fw= y looking symbol sea water (2010.62-168171.2727/h+32.935)ft^3

6 0
3 years ago
Other questions:
  • The water requirement for Class H cement is 38% (i.e.,water (%) by weight of cement),whereas the water requirement for barite is
    7·1 answer
  • A Service Schedule is...
    8·2 answers
  • Compute the volume percent of graphite, VGr, in a 3.2 wt% C cast iron, assuming that all the carbon exists as the graphite phase
    8·1 answer
  • Name the main classes of polymer and define their characteristic properties
    15·1 answer
  • Can someone teach me how to find all valid minterms of any given truth table?
    11·1 answer
  • Air is compressed in a well insulated compressor from 95 kPa and 27 C to 600 kPa and 277 C. Use the air tables; assume negligibl
    11·1 answer
  • Trapezoidal screw press project
    6·1 answer
  • Which option identifies the step skipped in the following scenario?
    9·2 answers
  • Three-dimensional measuring references all of these EXCEPT:
    10·1 answer
  • A. 50
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!