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
Stells [14]
3 years ago
15

Java

Computers and Technology
1 answer:
inna [77]3 years ago
3 0

Answer:

import java.util.Scanner;

public class num3 {

   public static void main(String[] args) {

     Scanner in = new Scanner(System.in);

       System.out.print("Enter two numbers: ");

       int num1 = in.nextInt();

       int num2 = in.nextInt();

       int sum = num1+num2;

       System.out.print("Do you want another operation: ");

       String ans = in.next();

       while(ans.equalsIgnoreCase("yes")){

           System.out.print("Enter two numbers:");

           num1= in.nextInt();

           num2 = in.nextInt();

           System.out.println("Do you want another operation: ");

           ans = in.next();

           sum = sum+(num1+num2);

       }

       System.out.println("sum = "+sum);

   }

}

Explanation:

In the program written in Java Programming language,

The scanner class is used to prompt and receive two numbers from the user which are stored as num1 and num2. Another variable sum is created to hold the sum of this numbers

Then the user is prompted to answer yes or no using Java's equal.IgnoreCase() method.

If the user enters yes, he/she is allowed to entered two more numbers that are countinually added to sum

If the user eventually enters a string that is not equal to yes. The loop terminates and the accumulated value of sum is printed.

You might be interested in
Competition between individuals in a population is due to (2 points)
madam [21]
Competition between individuals in a population is due to (2 points)
limited resources
5 0
4 years ago
How to make the heart symbol in photoshop
sveta [45]
Click the font drop-down box in the tool settings bar. Select "Arial." 6. Press "Alt-3" using your keyboard number pad's "3" key to insert the heart symbol<span>.</span>
3 0
4 years ago
Read 2 more answers
____ is the study of how computers can potentially improve without human programming.
Advocard [28]

Answer:

Machine Learning and/or Artificial Intelligence (AI)

5 0
1 year ago
An ______ is a simplified image. [4 letters]​
krok68 [10]
Is this dealing with the computer because I can help you then
7 0
3 years ago
Read 2 more answers
Which part of the faucet is the aerator?
sammy [17]
A faucet aerator<span> (or tap aerator) is often found at the tip of modern indoor water </span>faucets<span>.</span>
8 0
3 years ago
Other questions:
  • *****NEED HELP ASAP!!!! COMPUTER HELP!!!! PLEASE!**
    13·1 answer
  • What does a graphic organizer do
    6·1 answer
  • Harvey is creating a presentation for his school project. He wants to have the same look on all the slides of his presentation.
    6·2 answers
  • Somebody who is good at this stuff, please halp meh ;-;
    6·1 answer
  • Why does brainly have 3-2 sites? I'm asking since I get tired from making 3-2 accounts on each one. Well by checking each accoun
    12·1 answer
  • What is the definition of delimited text?
    14·2 answers
  • Write a function findWithinThreshold that identifies the elements of a given array that are inside a threshold value. Takes the
    13·1 answer
  • 2y/3 - y-1/6 + 7y-1/4 = 2 1/6​
    5·1 answer
  • Display ad traffic from mobile devices may appear to be unprofitable, but the ads might be profitable if
    6·1 answer
  • How does technology affect our daily lives essay
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!