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
NikAS [45]
3 years ago
14

Write a method that takes three numerical String values and sums their values.

Computers and Technology
2 answers:
anyanavicka [17]3 years ago
6 0

Answer:

Is in the provided screenshot!

Explanation:

All we need to do is use the built in function "parseInt" to turn a String into an Integer, then we can just add these and return it from the function!

I've also added some basic exception handling - if any one of the numbers aren't written in correctly then the program will just return '-1' instead of crashing.

Sphinxa [80]3 years ago
4 0

Answer:

<u>Algorithm</u>:

  1. Take a int variable c=0.
  2. Run the loop from 0 to String length.
  3. Get the each index value using charAt() method which will return the char value.
  4. Convert that char into int by typecasting or any other way.
  5. Now check that ASCII fall into the range of 48-57 for 0-9 int number.
  6. If it matches then first convert that number into integer using Integer.parseInt().
  7. Then add with the c and store to the same variable i.e c.
  8. Repeat from 3-7 till the end of the loop.
  9. At the end of loop , Print c outside the loop.

Explanation:

// Java program to calculate sum of all numbers present  

// in a string containing alphanumeric characters  

class GFG  

{  

   // Function to calculate sum of all numbers present  

   // in a string containing alphanumeric characters  

   static int findSum(String str)  

   {  

       // A temporary string  

       String temp = "";  

       // holds sum of all numbers present in the string  

       int sum = 0;  

       // read each character in input string  

       for(int i = 0; i < str.length(); i++)  

       {  

           char ch = str.charAt(i);  

           // if current character is a digit  

           if (Character.isDigit(ch))  

               temp += ch;  

           // if current character is an alphabet  

           else

           {  

               // increment sum by number found earlier  

               // (if any)  

               sum += Integer.parseInt(temp);  

               // reset temporary string to empty  

               temp = "0";  

           }  

       }  

       // atoi(temp.c_str()) takes care of trailing  

       // numbers  

       return sum + Integer.parseInt(temp);  

   }    

   // Driver code  

   public static void main (String[] args)  

   {      

       // input alphanumeric string  

       String str = "1abc5yz7";  

       System.out.println(findSum(str));  

   }  

}  

You might be interested in
You have instructed all administrators to disable all nonessential ports on servers at their sites. why are nonessential protoco
wlad13 [49]

The reason nonessential protocols are a security issue that you should be concerned about is that: A. nonessential ports provide additional areas of attack.

<h3>What is information security?</h3>

Information security can be defined as a preventive practice which is typically used to protect an information system (IS) that use, store or transmit information, from potential theft, attack, damage, or unauthorized access, especially through the use of a body of technologies, encryption, frameworks, processes and network engineers.

In Cyber security, the reason nonessential protocols are a security issue that an end user should be concerned about is that nonessential ports would provide additional areas of attack because all protocols have weaknesses based on the principle of least privilege.

Read more on information security here: brainly.com/question/14286078

#SPJ1

Complete Question:

You have instructed all administrators to disable all nonessential ports on servers at their sites. Why are nonessential protocols a security issue that you should be concerned about?

Nonessential ports provide additional areas of attack.

Nonessential ports can't be secured.

Nonessential ports require more administrative effort to secure.

3 0
2 years ago
Which OS does NOT provide users with a GUI?
vesna_86 [32]
The answer is C ms-dos
Side note:
GUI means graphical user interface. In other words, that means it looks pretty and has cool buttons, animations and cute stuff. MS-DOS is just a black screen with words on it. Definitely not cute or cool.
3 0
4 years ago
Please help me. i will mark you brailiest
Stolb23 [73]

Answer:

Simple, really

Explanation:

3Rd one is pretty easy, all you have to do is read closely.

3 0
3 years ago
What are the three parts of a camera
son4ous [18]

Answer: Camera lens, Film or sensors, and body.

Explanation: I researched it.

8 0
3 years ago
Which of the following statements is true about scalability? Choose 3 options.
Simora [160]

Answer:

4, 5, 2

Explanation:

just did it on edge :)

3 0
3 years ago
Read 2 more answers
Other questions:
  • business owners and managers may first balk at the idea of mobile officer workers because there may appear to be a lack of ___ w
    9·1 answer
  • In 2-3 sentences, describe a case where circuit-switching is better than packet-switching?
    9·1 answer
  • A study guide can be created
    6·2 answers
  • Your company received a call from a historical society inquiring about the possibility of networking a two-century-old building
    15·1 answer
  • Where could an identity thief access your personal information?
    13·1 answer
  • How can you enter Task Manager in Windows? Select 3 options. press Ctrl + Shift + Tab press Ctrl+Alt+Delete and then click Task
    8·1 answer
  • Nuclear batteries use devices called thermocouples, which convert the ____ of a nuclear reaction into electricity.
    9·1 answer
  • Out of a list of the values 8, 3, 30, 5, 15, and 6, what result would the MIN function return?
    9·2 answers
  • In python 3.17 LAB: Convert to dollars
    14·1 answer
  • The rectangle shape in flowchart is used for
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!