Question: Complete the program below named CountSevens so that it reads in an integer value, counts the number of digits in that number that have the
Complete the program below named CountSevens so that it reads in an integer value, counts the number of digits in that number that have the value 7, and prints out the final count. For example, the integer value, 57687728, would have 3 digits with the value 7.
Hint: you might consider using integer division or the modulus operator to separate out each digit of n.
Complete the following file:
CountSevens.java
import java.util.Scanner;
/** Counts the number of digits with value 7 in the decimal representation of the integer n */ public class CountSevens { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt();
// your work here
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
