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
Gnom [1K]
3 years ago
8

Lucky Sevens. Given a whole number, compute and display how many digits in the number are 7s. For example, the number of 7s in 3

482 is 0, while the number of 7s in 372771 is 3. Note: whole numbers are non-negative integers starting at zero {0, 1, 2, 3, 4, …}
Computers and Technology
1 answer:
Sveta_85 [38]3 years ago
6 0

Answer:

Code is in both c++ and java

Explanation:

C++ Code

#include<iostream>  

#include <sstream>  // for string streams  

#include <string>  // for string  

using namespace std;  

int main()  

{  

   int num;  

   cout<<"Enter Non-Negative number :";

  cin>> num;

   // declaring output string stream  

   ostringstream str1;  

   // Sending a number as a stream into output  

   // string  

   str1 << num;  

   // the str() coverts number into string  

   string geek = str1.str();  

   int count =0;

  for (int i = 0; i < geek.size(); i++){

    if(geek[i]=='7'){

     count++;  

 }

}

   // Displaying the string  

   cout << "the number of 7s in "<<num<< "is"<<count;

 

   return 0;  

}

Java Code

import java.util.Scanner;

public class LuckySeven{

   public static void main(String[] args){

       Scanner scanner = new Scanner(System.in);

       System.out.print("Enter Number :");

       int number = scanner.nextInt();

       String numberString = number+"";

       int count =numberString.length()- numberString.replaceAll("7","").length();

       System.out.println("Number of 7's in "+numberString+" are "+count);

   }

}

Code Explanation

First we need to take integer number as input from user.

As we need to iterate through all of the digits in number, that's why we need to convert integer to string as string is an array of character so we will iterate through number array and match the total count of 7 on every index.

At the end we will display the total count of 7 in number.

Sample Output

Case 1

Enter Non-Negative number :3482

the number of 7s in 3482 is 0

Case 2

Enter Non-Negative number :372771

the number of 7s in 372771 is 3

You might be interested in
What is a 'balanced' dfd?
jasenka [17]

Answer:

 The balanced DFD (Data flow diagram) is the concept of the balancing all the state and incoming and also outgoing flow in the system.

The balanced data flow diagram basically ensure that the output and input data flow maintain the consistency in the DFD and are properly aligned the flow of data.

A balanced DFD does not include any type of flowchart in the control statement and also does not contain any crossing lines.

8 0
3 years ago
Note oj cyber security​
dybincka [34]

Answer:

The answer to this question is given below in this explanation section.

Explanation:

                               "cyber security"

cyber security refers to the body of technologies,Processes and practices designed to protect networks,devices,programs and data from attack,damage or unauthorized  access.Cyber security may also be referred to as information technology security.

Importance:

                         Cyber security is important because government financial and medical organization collect process and store unprecedented amounts of data on computer and other devices.A significant portion of that data can be sensitive information,whether that be intellectual property financial data personal information or other type of data for which unauthorized access or exposure could have negative consequences.organizations transmit sensitive data across network and to other devices in the course of doing business,and cyber security describes the discipline dedicated to protecting that information and the systems  use to process or store it.

Challenges of cyber security:

                  For an effective cyber security an organization needs to coordinates its effort throughout its entire information systems.Elements of cyber components all the following:

  • Network security
  • Application security
  • Endpoint security
  • Data security
  • Identity management
  • Database and infrastructure security
  • cloud security
  • Mobile security

Managing cyber security:

            The national cyber security alliance,through recommends a top down  approach to cyber security in which corporate management leads the change in prioritizing cyber security management across all business practices. NCSA advises that companies must be prepaid to response to the inevitable cyber incident restore normal operations,and ensure that company assets and the company reputation are protected.

7 0
3 years ago
Victoria enjoys laughing with her friends as they walk around the track after school. Which best describes her hate rate during
Pachacha [2.7K]
Her heart rate would be 56 or 75 it high but not that high because shes walking
3 0
3 years ago
I have a summary to write for my robotics class but it is way too hard and i have a bery less time. If you can help me it would
Ierofanga [76]

Answer:

What is Robotics?

Robotics is the branch of technology that deal with the design, construction, operation and application of robots as well as computer system for there control, sensory feed back, and information processing. the design of given robotic system often contain principle of mechanical or electronic engineering and computer science. The word robotic was first used in 1941 by the writer Isaac Asimov.

Branches of robotics:

Artificial intelligence: The developing of an intelligence of machine and is a branch of computer science.

Nano Robotics : the field of creating machines that are at a scale of a nano meter.

Tele-presence: The study given to an illusion of being at a place without being there physically.

Robot Locomotion: The study of method that Robots used to transport them selves from place to another.

Robots have long captured the human imagination but despite many advances robots have yet to reach the potential so often envisioned in science fiction today engineers and computer scientist are still pursuing one missing ingredient high intelligence it would be nice for example: if robots possessed the intelligent needed to cope  with uncertainty, learn from experience and work as team.

Intelligent robots will be one of the engineering achievement of 21 century said Junku Yuh, how leads the robotics program in the national science foundation computers and information science and engineering directorate "we will see them more and more in our daily life".

5 0
3 years ago
Because it allows their files to be accessed from any device on the Internet, many users like to back-up their files using ___ s
77julia77 [94]

Answer:

Cloud

Explanation:

Cloud computing is a central form of storing data on a data center, provided online, to provides inexpensive and secure storage facilities and central accessing of document, using any device and accessing the data from anywhere and time.

Data stored in a clients computer system, would have to be transferred to another remote computer by using a portable storage, to share data. Using a cloud service or a database center service, a document can be accessed by a group of users at the same time, in different places, and assures a secure data in the database.

3 0
3 years ago
Other questions:
  • In a paragraph of no less than 125 words, describe how you would insert a graph in your word-processing document.
    8·2 answers
  • A. True <br> b. False: variables represent storage locations in the computer's memory.
    13·1 answer
  • In 125 words describe the steps to active listening.
    6·1 answer
  • Which is said to be ‘computer on a chip’
    8·1 answer
  • You are a network technician for a small corporate network. It's been decided that the office needs a wireless network for emplo
    6·1 answer
  • Problem 3. Consider the following recurrence, defined for n a power of 4 (for the time of some algorithm): T(n) = 3 if n = 1 2T(
    5·1 answer
  • According to the video, some workers who work for themselves, such as Actors, Musicians, or Writers, may have what sort of worke
    7·1 answer
  • What is a closed system?​
    7·1 answer
  • What is the most common knowledge computer programmers need in order
    15·2 answers
  • for a given array of integers perform operations on the array return the resulting array after all operations have been applied
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!